Retrofit 2 in Android 4.x Version












0















We are using Retrofit 2 and facing this below Exception in Android 4.x Versions and is working properly in other Android Versions. Added the code below



Caused by java.lang.NoClassDefFoundError: javax/annotation/Nullable
at java.lang.reflect.Field.getAnnotation(Field.java)
at java.lang.reflect.Field.getAnnotation(Field.java:212)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldNames(ReflectiveTypeAdapterFactory.java:72)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)
at com.google.gson.Gson.getAdapter(Gson.java:423)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:115)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:164)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)
at com.google.gson.Gson.getAdapter(Gson.java:423)
at retrofit2.converter.gson.GsonConverterFactory.requestBodyConverter(GsonConverterFactory.java:71)
at retrofit2.Retrofit.nextRequestBodyConverter(Retrofit.java:282)
at retrofit2.Retrofit.requestBodyConverter(Retrofit.java:262)
at retrofit2.ServiceMethod$Builder.parseParameterAnnotation(ServiceMethod.java:710)
at retrofit2.ServiceMethod$Builder.parseParameter(ServiceMethod.java:336)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:204)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
at $Proxy1.getMagGold(Unknown Source)
at com.amazon.DynamoDBOne.getMagGold(DynamoDBOne.java:82)
at com.task.SyncUserDatas.getUserGoldData(SyncUserDatas.java:330)
at com.task.SyncUserDatas.doInBackground(SyncUserDatas.java:292)
at com.task.SyncUserDatas.doInBackground(SyncUserDatas.java:57)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)


Below is the code



public interface ApiServices{
@POST("getGold")
Call<GetMagGoldResponse> getMagGold(@Header("Authorization") String Authorization, @Body UserId userId);
}
Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(<URL>)
.client(getLogClient())
.build();
ApiServices service = retrofit.create(ApiServices.class);

service.getMagGold(token, userId).execute().body();









share|improve this question




















  • 1





    post your code too.

    – Farhana
    Jan 2 at 7:21











  • NoClassDefFoundError is encountered when a class is present at compile time but not at runtime. Therefore, I believe the problem is being caused by the application not being able to find the 'annotation' class...

    – Nero
    Jan 2 at 7:42











  • Code Added.....

    – Arjun R
    Jan 2 at 8:15
















0















We are using Retrofit 2 and facing this below Exception in Android 4.x Versions and is working properly in other Android Versions. Added the code below



Caused by java.lang.NoClassDefFoundError: javax/annotation/Nullable
at java.lang.reflect.Field.getAnnotation(Field.java)
at java.lang.reflect.Field.getAnnotation(Field.java:212)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldNames(ReflectiveTypeAdapterFactory.java:72)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)
at com.google.gson.Gson.getAdapter(Gson.java:423)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:115)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:164)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)
at com.google.gson.Gson.getAdapter(Gson.java:423)
at retrofit2.converter.gson.GsonConverterFactory.requestBodyConverter(GsonConverterFactory.java:71)
at retrofit2.Retrofit.nextRequestBodyConverter(Retrofit.java:282)
at retrofit2.Retrofit.requestBodyConverter(Retrofit.java:262)
at retrofit2.ServiceMethod$Builder.parseParameterAnnotation(ServiceMethod.java:710)
at retrofit2.ServiceMethod$Builder.parseParameter(ServiceMethod.java:336)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:204)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
at $Proxy1.getMagGold(Unknown Source)
at com.amazon.DynamoDBOne.getMagGold(DynamoDBOne.java:82)
at com.task.SyncUserDatas.getUserGoldData(SyncUserDatas.java:330)
at com.task.SyncUserDatas.doInBackground(SyncUserDatas.java:292)
at com.task.SyncUserDatas.doInBackground(SyncUserDatas.java:57)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)


Below is the code



public interface ApiServices{
@POST("getGold")
Call<GetMagGoldResponse> getMagGold(@Header("Authorization") String Authorization, @Body UserId userId);
}
Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(<URL>)
.client(getLogClient())
.build();
ApiServices service = retrofit.create(ApiServices.class);

service.getMagGold(token, userId).execute().body();









share|improve this question




















  • 1





    post your code too.

    – Farhana
    Jan 2 at 7:21











  • NoClassDefFoundError is encountered when a class is present at compile time but not at runtime. Therefore, I believe the problem is being caused by the application not being able to find the 'annotation' class...

    – Nero
    Jan 2 at 7:42











  • Code Added.....

    – Arjun R
    Jan 2 at 8:15














0












0








0








We are using Retrofit 2 and facing this below Exception in Android 4.x Versions and is working properly in other Android Versions. Added the code below



Caused by java.lang.NoClassDefFoundError: javax/annotation/Nullable
at java.lang.reflect.Field.getAnnotation(Field.java)
at java.lang.reflect.Field.getAnnotation(Field.java:212)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldNames(ReflectiveTypeAdapterFactory.java:72)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)
at com.google.gson.Gson.getAdapter(Gson.java:423)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:115)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:164)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)
at com.google.gson.Gson.getAdapter(Gson.java:423)
at retrofit2.converter.gson.GsonConverterFactory.requestBodyConverter(GsonConverterFactory.java:71)
at retrofit2.Retrofit.nextRequestBodyConverter(Retrofit.java:282)
at retrofit2.Retrofit.requestBodyConverter(Retrofit.java:262)
at retrofit2.ServiceMethod$Builder.parseParameterAnnotation(ServiceMethod.java:710)
at retrofit2.ServiceMethod$Builder.parseParameter(ServiceMethod.java:336)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:204)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
at $Proxy1.getMagGold(Unknown Source)
at com.amazon.DynamoDBOne.getMagGold(DynamoDBOne.java:82)
at com.task.SyncUserDatas.getUserGoldData(SyncUserDatas.java:330)
at com.task.SyncUserDatas.doInBackground(SyncUserDatas.java:292)
at com.task.SyncUserDatas.doInBackground(SyncUserDatas.java:57)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)


Below is the code



public interface ApiServices{
@POST("getGold")
Call<GetMagGoldResponse> getMagGold(@Header("Authorization") String Authorization, @Body UserId userId);
}
Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(<URL>)
.client(getLogClient())
.build();
ApiServices service = retrofit.create(ApiServices.class);

service.getMagGold(token, userId).execute().body();









share|improve this question
















We are using Retrofit 2 and facing this below Exception in Android 4.x Versions and is working properly in other Android Versions. Added the code below



Caused by java.lang.NoClassDefFoundError: javax/annotation/Nullable
at java.lang.reflect.Field.getAnnotation(Field.java)
at java.lang.reflect.Field.getAnnotation(Field.java:212)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldNames(ReflectiveTypeAdapterFactory.java:72)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)
at com.google.gson.Gson.getAdapter(Gson.java:423)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:115)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:164)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)
at com.google.gson.Gson.getAdapter(Gson.java:423)
at retrofit2.converter.gson.GsonConverterFactory.requestBodyConverter(GsonConverterFactory.java:71)
at retrofit2.Retrofit.nextRequestBodyConverter(Retrofit.java:282)
at retrofit2.Retrofit.requestBodyConverter(Retrofit.java:262)
at retrofit2.ServiceMethod$Builder.parseParameterAnnotation(ServiceMethod.java:710)
at retrofit2.ServiceMethod$Builder.parseParameter(ServiceMethod.java:336)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:204)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
at $Proxy1.getMagGold(Unknown Source)
at com.amazon.DynamoDBOne.getMagGold(DynamoDBOne.java:82)
at com.task.SyncUserDatas.getUserGoldData(SyncUserDatas.java:330)
at com.task.SyncUserDatas.doInBackground(SyncUserDatas.java:292)
at com.task.SyncUserDatas.doInBackground(SyncUserDatas.java:57)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)


Below is the code



public interface ApiServices{
@POST("getGold")
Call<GetMagGoldResponse> getMagGold(@Header("Authorization") String Authorization, @Body UserId userId);
}
Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(<URL>)
.client(getLogClient())
.build();
ApiServices service = retrofit.create(ApiServices.class);

service.getMagGold(token, userId).execute().body();






android retrofit2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 8:14







Arjun R

















asked Jan 2 at 7:20









Arjun RArjun R

314




314








  • 1





    post your code too.

    – Farhana
    Jan 2 at 7:21











  • NoClassDefFoundError is encountered when a class is present at compile time but not at runtime. Therefore, I believe the problem is being caused by the application not being able to find the 'annotation' class...

    – Nero
    Jan 2 at 7:42











  • Code Added.....

    – Arjun R
    Jan 2 at 8:15














  • 1





    post your code too.

    – Farhana
    Jan 2 at 7:21











  • NoClassDefFoundError is encountered when a class is present at compile time but not at runtime. Therefore, I believe the problem is being caused by the application not being able to find the 'annotation' class...

    – Nero
    Jan 2 at 7:42











  • Code Added.....

    – Arjun R
    Jan 2 at 8:15








1




1





post your code too.

– Farhana
Jan 2 at 7:21





post your code too.

– Farhana
Jan 2 at 7:21













NoClassDefFoundError is encountered when a class is present at compile time but not at runtime. Therefore, I believe the problem is being caused by the application not being able to find the 'annotation' class...

– Nero
Jan 2 at 7:42





NoClassDefFoundError is encountered when a class is present at compile time but not at runtime. Therefore, I believe the problem is being caused by the application not being able to find the 'annotation' class...

– Nero
Jan 2 at 7:42













Code Added.....

– Arjun R
Jan 2 at 8:15





Code Added.....

– Arjun R
Jan 2 at 8:15












1 Answer
1






active

oldest

votes


















1














put this line in your gradle.build and you are good to go.



implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54002629%2fretrofit-2-in-android-4-x-version%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    put this line in your gradle.build and you are good to go.



    implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'





    share|improve this answer




























      1














      put this line in your gradle.build and you are good to go.



      implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'





      share|improve this answer


























        1












        1








        1







        put this line in your gradle.build and you are good to go.



        implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'





        share|improve this answer













        put this line in your gradle.build and you are good to go.



        implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 2 at 8:00









        Jay DangarJay Dangar

        714518




        714518
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54002629%2fretrofit-2-in-android-4-x-version%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

            Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

            A Topological Invariant for $pi_3(U(n))$