After adding the new dependencies in the build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.thebluealliance:spectrum:0.5.0'
compile 'com.github.sillebille:dynamic-calendar:1.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:support-v4:23.0.1'}
Caused the following exception
Caused by: java.lang.NoClassDefFoundError: android.support.design.internal.NavigationMenuPresenter
at android.support.design.widget.NavigationView.<init>(NavigationView.java:80)
at android.support.design.widget.NavigationView.<init>(NavigationView.java:92)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:611)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:747)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:508)
at android.view.LayoutInflater.inflate(LayoutInflater.java:418)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
Is there any problem the added library or some proguard has to be added to make this work?
A "NoClassDefFoundError" means that you're trying to use a class that either isn't defined, or doesn't exist. Double check that any libraries you're using are installed correctly if they're open source, and if you're quite sure that everything is correct, it might just be a problem with the API. I've run into this error loads of times because API's are either riddled with errors or are simply not complete. Probably not what you wanted to hear, but I hope it helps!
Related
I'm using retrofit (2.7.2) and OkHttp version (4.4.0) in an Android project and I'm facing a crash on a request.
Dependencies:
kapt("com.squareup.moshi:moshi-kotlin-codegen:1.9.2")
implementation 'com.squareup.moshi:moshi:1.9.2'
implementation 'com.squareup.retrofit2:retrofit:2.7.2'
implementation 'com.squareup.retrofit2:converter-moshi:2.7.2'
implementation("com.squareup.okhttp3:okhttp:4.4.0")
implementation("com.squareup.okhttp3:okhttp-tls:4.4.0")
implementation "com.squareup.okhttp3:logging-interceptor:4.4.0"
Crash:
java.lang.NoSuchMethodError: No virtual method
toString(Z)Ljava/lang/String; in class Lokhttp3/Cookie; or its super
classes (declaration of 'okhttp3.Cookie' appears in
/data/app/com.package-1/base.apk:classes3.dex)
at okhttp3.JavaNetCookieJar.saveFromResponse(JavaNetCookieJar.java:45)
at com.facebook.react.modules.network.ReactCookieJarContainer.saveFromResponse(ReactCookieJarContainer.java:36)
at okhttp3.internal.http.HttpHeaders.receiveHeaders(HttpHeaders.kt:207)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:85)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:74)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:502)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
You're pulling in an old version of okhttp-urlconnection, and it is incompatible with the current version of the OkHttp core library.
You can fix by adding an explicit dependency on okhttp-urlconnection:
implementation("com.squareup.okhttp3:okhttp-urlconnection:4.4.1")
Or by adopting OkHttp’s new BOM for versions:
dependencies {
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.4.1"))
implementation("com.squareup.okhttp3:okhttp") // No version!
implementation("com.squareup.okhttp3:okhttp-urlconnection") // No version!
}
I used following okhttp3 versions and woked fine for me...
implementation 'com.squareup.okhttp3:okhttp:4.7.2'
implementation 'com.squareup.okhttp3:logging-interceptor:4.4.1'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:4.4.1'
Please make sure that build.gradle file hase a same version for belowed dependencies and if you have this below version and getting above error than change version for them and your issue has been solved.:
implementation 'com.squareup.okhttp3:logging-interceptor:4.8.0'
implementation 'com.squareup.okhttp3:okhttp:4.8.0'
Change the version with below :
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.okhttp3:okhttp:3.4.1'
I wanted to add that this error was showing up after ejecting from Expo in React Native.
The solution was to go to add the following to android/app/build.gradle (inside dependencies):
compile "com.squareup.okhttp3:okhttp:4.2.1"
compile "com.squareup.okhttp3:logging-interceptor:4.2.1"
compile "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"
They would look like this:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
// you can insert it here
compile "com.squareup.okhttp3:okhttp:4.2.1"
compile "com.squareup.okhttp3:logging-interceptor:4.2.1"
compile "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"
}
(Note: Check the versions in the Maven Repository
I'm trying to build an app with the Here Maps API.
Based on this example , I try to build the very basic form of a Here map in my app.
By following the instructions I still had to manage a load of issues. I managed most of them I think but there are some problems with or in the Java compiler (I guess?). It tells me that a deprecated API has to be overwritten.
When I use the "Make Project" function, Android Studio gives me 4 errors after checking the Java compiler:
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while
merging dex archives
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: com.a.a.a$a
Is there something with the example from Here Developers that is outdated right now and has to be fixed manually? I just used the instructions in that example, nothing else.
Please check if your gradle file dependencies are looking something like this. Include HERE-sdk.aar explicitly like given below:
dependencies {
implementation fileTree(dir: 'libs', include: ['HERE-sdk.aar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile 'com.google.code.gson:gson:2.8.0'
}
Which version of Android Studio do you use? Do you use additional dependencies in your app?
Seems there are mismatches in dex archives. To solve that, could you pease try to update app/build.gradle with the following?
android {
defaultConfig {
multiDexEnabled true
}
}
Error:Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. > Could not create service of type AnnotationProcessorDetector using JavaGradleScopeServices.createAnnotationProcessorDetector().
I'm getting the above error, I tried alot of things (Set jdk path,add support-annotation library e.t.c)to remove this error but nothing changed. I'm using Android Studio 3.0.1 and toolbar inside my app,minSdk 15 ,maxSdk 26.
This is my gradle:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0
testImplementation 'junit:junit:4.12'
There would be sure some error with this, try to toggle gradle view. See below image. You will find error..
Also click on red titled line in this view, it will tell you error.
Ok this is very weird. I'm suddenly getting this crash in my logcat when I run the app in the emulator, when before I've never had it, and I've not made any changes to my app since the last time I ran it in the emulator a few weeks ago and it was working.
Here's the full error:
java.lang.NoSuchMethodError: No static method setFactory2(Landroid/view/LayoutInflater;Landroid/view/LayoutInflater$Factory2;)V in class Landroid/support/v4/view/LayoutInflaterCompat; or its super classes (declaration of 'android.support.v4.view.LayoutInflaterCompat' appears in /data/app/com.pa.myapp-2/base.apk)
at android.support.v7.app.AppCompatDelegateImplV9.installViewFactory(AppCompatDelegateImplV9.java:1060)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at com.pa.myapp.SplashActivity.onCreate(SplashActivity.java:36)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
I tried Google searching but can't find this crash error anywhere else. I tried reinstalling Android Studio but it didn't help. Some "similar" errors I've found on stackoverflow says it may be related to appcompat version, but I've tried different versions with no luck. Here's my gradle compiles:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.johnhiott:DarkSkyApi:v0.1.5'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-ads:11.0.4'
compile 'com.google.code.gson:gson:2.7'
compile 'com.sickmartian.calendarview:calendarview:1.0.0'
compile 'com.squareup.retrofit2:converter-scalars:2.2.0'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.anjlab.android.iab.v3:library:1.0.38'
compile 'com.google.maps.android:android-maps-utils:0.5'
compile 'com.github.robertsimoes:Shareable:0.1.0'
compile 'com.zendesk:sdk:1.10.0.1'
compile 'com.zopim.android:sdk:1.3.3.1'
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.google.firebase:firebase-core:11.0.4'
testCompile 'junit:junit:4.12'
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
compile 'com.codemybrainsout.rating:ratingdialog:1.0.8'
}
The logcat error says this line is to blame in my SplashActivity.java file, but I haven't modified this java file at all since I originally created the app 2 years ago.
super.onCreate(savedInstanceState);
may be this error occurs because of your old dependency versions, try upgrading them. If the problem persist even after that please drop your splash activity code.
Also you should try upgrading your version.
This is not the exact answer but I have the same issue and I resolved it by changing the dependency versions, your issue could be similar so you can change the external dependencies version and see if your issue is resolved or not.
I created a new project in Android Studio 1.1 and I built successfully. After that, I added a jar libraries and updated build.gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/commons-logging-1.1.1.jar')
compile files('libs/google-api-client-1.18.0-rc.jar')
compile files('libs/google-api-client-android-1.18.0-rc.jar')
compile files('libs/google-api-client-appengine-1.18.0-rc.jar')
compile files('libs/google-api-client-gson-1.18.0-rc.jar')
compile files('libs/google-api-client-jackson2-1.18.0-rc.jar')
}
Now, I am getting error "Local path doesn't exist."
I search other questions about this problem but I can't solve it. Help me please!
If you added jar libraries, your Gradle file should have updated itself correctly. Local path doesn't exist means that one of the files you want to compile is not in the path you have specified.
If you used
compile fileTree(dir: 'libs', include: ['*.jar'])
Then no need to add each .jar file one by one ,it means you have to remvoe following form your build.gradle.
compile files('libs/commons-logging-1.1.1.jar')
compile files('libs/google-api-client-1.18.0-rc.jar')
compile files('libs/google-api-client-android-1.18.0-rc.jar')
compile files('libs/google-api-client-appengine-1.18.0-rc.jar')
compile files('libs/google-api-client-gson-1.18.0-rc.jar')
compile files('libs/google-api-client-jackson2-1.18.0-rc.jar')