I have been working on a project that has been perfectly fine, until i included the android-smack-xmpp library.
After this inclusion, i am not able to run the app on devices (API < 21) on debug mode. However i am able to run it on release build variant.
Process: com.example, PID: 496
java.lang.NoClassDefFoundError: com.example.network.ServerCalls$3
at com.example.network.ServerCalls.initData(ServerCalls.java:167)
at com.example.ui.fragmentsAndActivities.homeFeed.HomePageActivity.onCreate(HomePageActivity.java:212)
at android.app.Activity.performCreate(Activity.java:5248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
ServerCalls is included in the HomePageActivity, and compilation works just fine. What is that i could be missing here ?
Also HomePageActivity.java:212 is :
ServerCalls.samosaInitData()
Edit : I have been able to get it working my setting minifyEnabled and shrinkResources to true in gradle for the debug build. This is probably pointing at improper linking in the JVM. But this looks like a hack to me. Can somebody point me to a cleaner way of doing the same?
The error was multi-dexing the solution.
The smack-api library introduction led to the 64k dex limit to be exceeded.
Multidexing the solution does the trick.
It looks like you don't export your library in the final .apk file.
You have to choose the Compile option in your Android Studio project settings in the Dependencies section.
Related
After upgrading to the latest version of the support library, I'm no longer able to run the app on Android 2.3.3. The app crashes during startup with the
11-01 13:53:16.580 2115-2115/no.bouvet.routeplanner.atb E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoSuchMethodError: android.view.View.isAttachedToWindow
at android.support.v7.widget.ForwardingListener$2.(ForwardingListener.java:102)
at android.support.v7.widget.ForwardingListener.addDetachListenerBase(ForwardingListener.java:101)
at android.support.v7.widget.ForwardingListener.(ForwardingListener.java:78)
at android.support.v7.widget.ActionMenuPresenter$OverflowMenuButton$1.(ActionMenuPresenter.java:650)
at android.support.v7.widget.ActionMenuPresenter$OverflowMenuButton.(ActionMenuPresenter.java:650)
at android.support.v7.widget.ActionMenuPresenter.initForMenu(ActionMenuPresenter.java:114)
at android.support.v7.view.menu.MenuBuilder.addMenuPresenter(MenuBuilder.java:262)
at android.support.v7.widget.ActionMenuView.getMenu(ActionMenuView.java:656)
at android.support.v7.widget.Toolbar.ensureMenu(Toolbar.java:1037)
at android.support.v7.widget.Toolbar.getMenu(Toolbar.java:1008)
at android.support.v7.widget.ToolbarWidgetWrapper.getMenu(ToolbarWidgetWrapper.java:676)
at android.support.v7.app.ToolbarActionBar.getMenu(ToolbarActionBar.java:595)
at android.support.v7.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:447)
at android.support.v7.app.ToolbarActionBar$1.run(ToolbarActionBar.java:61)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
The dependencies used are:
compile 'com.android.support:support-v4:25.0.0'
compile 'com.android.support:support-compat:25.0.0'
compile 'com.android.support:support-core-ui:25.0.0'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:preference-v7:24.2.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.maps.android:android-maps-utils:0.4'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:recyclerview-v7:24.2.1'
The error disappears of I downgrade to 24.2.2, but this causes other problems (when using the default android searchview, the text that the user enters is not visible, even though the autocomplete works fine)
I assume this is a bug in the support library. Have anyone seen the same problem and know of a fix?
It's an issue with Support Library 25.0.0:https://code.google.com/p/android/issues/detail?id=225647.
You can reproduce the issue by creating a new project and using the standard Basic Activity template in Android Studio. The app will crash on setSupportActionBar(toolbar); on devices API 11 and below.
I didn't find another solution except to downgrade support library version.
The problem is solved with new realease:
Android Support Library, revision 25.0.1 (November 2016)
https://developer.android.com/topic/libraries/support-library/revisions.html
I am not an Android developer, but I am trying to upgrade the Facebook SDK for an app I have on Android Studio. The previous SDK was 3.5 and I am trying to add 4.4.1
I have written the login class by following the getting started guide but now when I try to launch the app on a device, although it compiles just fine, it crashes on startup.
I get the following error:
08-05 21:05:25.128 25207-25207/? E/dalvikvm﹕ Could not find class
'com.history.HistoryOrder', referenced from method
com.service.Global. 08-05 21:05:25.138 25207-25207/?
E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at com.imperautus.testProject.ActivitySplash.onCreate(ActivitySplash.java:61)
at android.app.Activity.performCreate(Activity.java:5326)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309)
at android.app.ActivityThread.access$700(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5317)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: com.history.HistoryOrder
at com.service.Global.(Global.java:113)
at com.imperautus.testProject.ActivitySplash.onCreate(ActivitySplash.java:61)
at android.app.Activity.performCreate(Activity.java:5326)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309)
at android.app.ActivityThread.access$700(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5317)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
What I see is that it complaints that it cannot find the class com.history.HistoryOrder but this class is in this exact place and it worked before the transition to the new Facebook SDK (I haven't touched the class' code).
The Global.java:113 says:
public static ArrayList<HistoryOrder> historyOrderList = new ArrayList<HistoryOrder>();
public static HistoryOrder historyOrderItem = new HistoryOrder();
I also changed all references in my code from app.Fragment to the support.v4.app.Fragment version because I thought that this caused the problem.
Any clues?
java.lang.NoClassDefFoundError is propably thrown because you have reached the 65k limit http://developer.android.com/tools/building/multidex.html#about
If you need to go beyond 65k limit you must include multidex support
gradle:
defaultConfig {
...
multiDexEnabled true
}
...
dependencies {
compile 'com.android.support:multidex:1.0.1'
...
}
Manifest:
<application
...
android:name="android.support.multidex.MultiDexApplication">
If you have a Custom Application class:
extend MultiDexApplication or add MultiDex.install(getBaseContext()); to your CustomApplication onCreate()
Note that on some low-end devices adding
MultiDex.install(getBaseContext()); to your CustomApplication onCreate()
can still throw java.lang.NoClassDefFoundError:
If so try adding MultiDex.install to attachBaseContext(Context base) instead
public class CustomApplication extends Application {
...
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(base);
}
...
ok, it seems that the error was due to a very different reason:
The app was updated to use Google Services 7.5 which made the methods go to more than 65k which made me to add the mutiDexEnabled to true.
I don't know if the code needs to be changed to support that, but it seems that after making this change, the app was crashing at random points (when I remarked the history call, the reachability class was crashing, when removed the reachability another, etc.
of course all classes were at the right place when the compiler complained about not finding them
This made me wonder if the multidex caused that so I removed some of the libraries like going from 7.5 verson of google play to 6.5
The app compiles and runs just fine now, allowing me to add the FB sdk 4+
I post this here, so it may help other people having problems without being able to understand where they come from.
I think you set the wrong class path so 1st check your class path
It will solve your problem
I have an app which works perfect in all 4.x devices, but now I have a report of the app not working on a samsung_gt (advance) android 2.3.6. Here is the trace:
FATAL EXCEPTION: main
java.lang.VerifyError: com.bamobile.fdtks.activities.MainActivity
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1409)
at android.app.Instrumentation.newActivity(Instrumentation.java:1024)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
at android.app.ActivityThread.access$1500(ActivityThread.java:121)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3770)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
at dalvik.system.NativeStart.main(Native Method)
I have the latest support jar (v4) and have already patched the gson library in case the phone is already using it. The problem seems to be the the support lib. Any ideas? Thank you very much!
The most common cause of java.lang.VerifyError is having a class that uses methods that are not available on the version of Android where the app is running.
Based on your stacktrace, it seems that com.bamobile.fdtks.activities.MainActivity is using a method that is not available on Android 2.3.6, hence the "verification error" that you're seeing.
To fix it, change the minSdkVersion and of your app to 9 or 10 (Android 2.3.6) and look for errors/warnings about unsupported methods for that version of Android. You can also change (temporarily) both minSdkVersion and targetSdkVersion to 9 to force the compiler to fail when you use methods that are not found in Gingerbread devices.
I am having issues when i try to add a spatialite database to my android studio projet.I followed this tutorial https://www.gaia-gis.it/fossil/libspatialite/wiki?name=spatialite-android-tutorial , as mentioned i added two folders to my project :
the native spatialite libraries: they are places in a folder named libs in my App directory and contains several folders for different platforms that hold the main library, called libspatialite.so
the basic API classes, contained in the jsqlite package
Despite this ,i am getting this error :
11-13 13:52:17.358 1853-1853/liara.geodatamining W/System.err﹕ Unable to load sqlite_jni: java.lang.UnsatisfiedLinkError: Couldn't load proj from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/liara.geodatamining-2.apk"],nativeLibraryDirectories=[/data/app-lib/liara.geodatamining-2, /system/lib]]]: findLibrary returned null
11-13 13:52:17.358 1853-1853/liara.geodatamining W/dalvikvm﹕ No implementation found for native Ljsqlite/Database;.internal_init:()V
11-13 13:52:17.358 1853-1853/liara.geodatamining W/dalvikvm﹕ Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Ljsqlite/Database;
11-13 13:52:17.358 1853-1853/liara.geodatamining W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb2d19b20)
11-13 13:52:17.358 1853-1853/liara.geodatamining E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: liara.geodatamining, PID: 1853
java.lang.UnsatisfiedLinkError: Native method not found: jsqlite.Database.internal_init:()V
at jsqlite.Database.internal_init(Native Method)
at jsqlite.Database.<clinit>(Database.java:951)
at liara.geodatamining.map.onCreate(map.java:116)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Am i missing something ?
This sounds a lot like you haven't included the appropriate version of the NDK for your emulator. Per the Android docs, the following platforms support Android NDK
ARM
ARM-NEON
x86
MIPS
The most common by far for real devices is ARM (armeabi-v7a). In fact, it's probably almost no loss to not include anything except for this for a published build. But the emulators often work off of x86. I know I have a NDK file for x86 that I remove every time I'm ready to build for release, and re-add when I want to use my desktop emulator.
if you're only using .so files and not compiling any C/C++ sources yourself, you don't need the NDK.
With Android Studio, the place where you drop .so files isn't the same than with eclipse. Now it's inside jniLibs/<ABI> where ABI can be armeabi, armeabi-v7a, x86, x86_64, mips, mips64, arm64-v8a.
You can check that your .so files are properly integrated by opening your APK as a zip file and simply checking that your .so files are inside lib/<abi> folders.
I have had my first errors come through via the developer console on a published app. The errors are:
java.lang.RuntimeException: Unable to start activity ComponentInfo{fetchfree.diss.ellis/fetchfree.diss.ellis.Intro}:
android.content.res.Resources$NotFoundException: Resource ID #0x7f030007
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030007
at android.content.res.Resources.getValue(Resources.java:892)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:1869)
at android.content.res.Resources.getLayout(Resources.java:731)
at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:210)
at android.app.Activity.setContentView(Activity.java:1647)
at fetchfree.diss.ellis.Intro.onCreate(Intro.java:47)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more
The app is running fine on my devices (S2,S3,S4 and galaxy ace) and the emulator and have not been able to replicate this. The resources its referring to at #0x7f030007 is a layout file for my setContentView of the Intro activity.
Resources:
Layout-normal-hdpi
Layout-normal-mdpi
Layout-sw360dp
My manifest states:
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="false"
android:smallScreens="false" />
I've seen this happen generally because the version uploaded to the playstore would not match the release apk. Best way is to clean the project in eclipse, build, release and then upload the apk to the play store. If this still happens you can check for a few more things I've gathered while searching for a similar issue on SO
1.) Make sure that your imports are correct. R.java must be your local R.java and not Android.R . Do a check in all your files
2.) Make sure you are not passing integer values to Views.
For instance dont do this
int i = 5;
myTextView.setText(i);
But do this
myTextView.setText(String.valueOf(i));
I suspect this to be a problem with you , so scan your code for this type of errors.
The compiler will not complain.
3.) Use this way of declaration
android:id="#id/android:list"
rather than
android:id="#android:id/list"
for id declarations
Make these changes if any, clean, build and upload. Should work.