ListViewAnimations NoClassDefFound error - java

I am using ListViewAnimations core library version 3.1.0 in my android application. I have only included lib-core library as per the setup instructions. But unfortunately I am receiving following error java.lang.NoClassDefFoundError:
java.lang.NoClassDefFoundError: Failed resolution of: [Lcom/nineoldandroids/animation/Animator;
11-23 14:47:18.489 14928-14928/com.gi.giml E/AndroidRuntime: at com.nhaarman.listviewanimations.appearance.AnimationAdapter.animateViewIfNecessary(AnimationAdapter.java:174)
11-23 14:47:18.489 14928-14928/com.gi.giml E/AndroidRuntime: at com.nhaarman.listviewanimations.appearance.AnimationAdapter.getView(AnimationAdapter.java:145)
11-23 14:47:18.489 14928-14928/com.gi.giml E/AndroidRuntime: at android.widget.AbsListView.obtainView(AbsListView.java:2346)
11-23 14:47:18.489 14928-14928/com.gi.giml E/AndroidRuntime: at android.widget.ListView.makeAndAddView(ListView.java:1875)
11-23 14:47:18.489 14928-14928/com.gi.giml E/AndroidRuntime: at android.widget.ListView.fillDown(ListView.java:702)
11-23 14:47:18.489 14928-14928/com.gi.giml E/AndroidRuntime: at android.widget.ListView.fillFromTop(ListView.java:763)
11-23 14:47:18.489 14928-14928/com.gi.giml E/AndroidRuntime: at android.widget.ListView.layoutChildren(ListView.java:1684)
11-23 14:47:18.489 14928-14928/com.gi.giml E/AndroidRuntime: at android.widget.AbsListView.onLayout(AbsListView.java:2148)
11-23 14:47:18.489 14928-14928/com.gi.giml E/AndroidRuntime: at android.view.View.layout(View.java:16630)
11-23 14:47:18.489 14928-14928/com.gi.giml E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5437)
11-23 14:47:18.489 14928-14928/com.gi.giml E/AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
I am using this animation library in my app like below:
ListView lv = new ListView(getActivity());
SwingBottomInAnimationAdapter bottomInAnimationAdapter = new SwingBottomInAnimationAdapter(new ArrayAdapter<String>(getActivity(), R.layout.subgroup_list_layout, R.id.textView, result));
bottomInAnimationAdapter.setAbsListView(lv);
lv.setAdapter(bottomInAnimationAdapter);
Any idea what I am doing wrong?

ListViewAnimations is based on NineOldAndroids and several classes reference com.nineoldandroids.animation.Animator directly. So you need to include this library as well.
If you're using gradle, this is done automatically by only declaring
dependencies {
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0#aar'
}
in your build.gradle. The same holds if you're using Maven and pom.xml. Otherwise you need to follow the instructions on the page you linked yourself:
Download the jar files you need: (lib-core)
Download the latest NineOldAndroids.jar file
Add the .jar files to your project's libs folder, or add them as external jars to your project's build path.

You should also include "nineoldandroids-2.4.0.jar" file in your project along with dependencies {
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0#aar'
}
add jar file to the lib folder and add this line in dependency
compile files('libs/nineoldandroids-2.4.0.jar') it works fine for this error "java.lang.NoClassDefFoundError: Failed resolution of: [Lcom/nineoldandroids/animation/Animator;"
link to download jar file https://github.com/downloads/JakeWharton/NineOldAndroids/nineoldandroids-2.4.0.jar

Related

Android App Crashes on Real Device If apk is manually installed

My Application is running fine in Emulators and even in real devices installed by android studio for debugging purpose, but it is crashing if installed manually using apk file.
I am ready to paste any other codes, like Activity if required.
Here is the logcat:
04-14 12:20:44.392 6220-6220/? I/art: Late-enabling -Xcheck:jni
04-14 12:20:44.465 6220-6220/test.planner W/System: ClassLoader referenced unknown path: /data/app/test.planner-1/lib/arm
04-14 12:20:44.467 6220-6220/test.planner I/InstantRun: starting instant run server: is main process
04-14 12:20:44.470 6220-6220/test.planner D/AndroidRuntime: Shutting down VM
04-14 12:20:44.471 6220-6220/test.planner E/AndroidRuntime: FATAL EXCEPTION: main
Process: test.planner, PID: 6220
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{test.planner/test.planner.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "test.planner.MainActivity" on path: DexPathList[[zip file "/data/app/test.planner-1/base.apk"],nativeLibraryDirectories=[/data/app/test.planner-1/lib/arm, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "test.planner.MainActivity" on path: DexPathList[[zip file "/data/app/test.planner-1/base.apk"],nativeLibraryDirectories=[/data/app/test.planner-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Suppressed: java.lang.ClassNotFoundException: test.planner.MainActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Just go to:
Android Studio --> File --> Setting --> Build, execution, deploy --> Instant run.
and disable instant run.
If you just upgraded your android studio.
You will not have this option to disable -> Instant Run. (not on the menu)
Seems like with new android studio and gradle upgrade in order to install an apk you need to properly build it.
Option 1: with gradle from command line
./gradlew :appName:clean
./gradlew :appName:build
Option 2: from android studio
Android Studio -> build -> build APK (or generate sighed APK)
The generated apk can be installed fine on a device.
Note: if you start a new applicate with this version of android studio you will see that when you run from studio there is no apk generated anymore.
I faced the similar problem.
Note the size of Apk, it would be very small in size , this is because of the instant run feature in enabled. Just disable it
May be Android Studio is not including all files in Apk, when we use the instant run to fasten the process.
Any body know why this happening?
Go to :
Android Studio --> File --> Setting --> Build, execution, deploy --> Instant run.
Android Studio --> File --> Setting --> Build, execution, deploy --> Instant run.
and disable instant run.

ApplicationClass ClassNotFoundException

I'm using the application class , so I had to create the manifest file, as follows:
<application
android.name="com.moonae.android.common.ApplicationClass"
android.icon="#drawble/ic_launcher"
android.largeHeap="true"
....>
<activity..../>
I have to work normally without problems when testing , often the error occurred in the Google Play Store error report.
But the error report is posted on the Android version 4.4 , I even tested at 4.4 operate normally.
If the person experiencing this problem help me.
java.lang.RuntimeException: Unable to instantiate application com.moonae.android.common.ApplicationClass: java.lang.ClassNotFoundException: Didn't find class "com.culturelandnew.android.common.ApplicationClass" on path: DexPathList[[],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4524)
at android.app.ActivityThread.access$1500(ActivityThread.java:163)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5335)
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:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.moonae.android.common.ApplicationClass" on path: DexPathList[[],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.Instrumentation.newApplication(Instrumentation.java:993)
at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
... 11 more
<application
android.name="com.moonae.android.common.ApplicationClass"
android.icon="#drawble/ic_launcher"
android.largeHeap="true"
....>
<activity..../>
is this a typo? i have not seen this before i mean android.name to android:name..btw
quick suggestion, remove your application tag, and use the eclipse gui side to search the application class and reference it.. mostly it references the it without package name included.. like this.. =>
<application
android:name="ApplicationClass"
android:icon="#drawble/ic_launcher"
android:largeHeap="true"
....>

DrawerLayout not found in Android Maven project at runtime

Okay, so I've been trying to figure out this problem for a few weeks now and been on StackOverflow profusely viewing similar problems and trying to apply them to my own situation to no avail. I am worried I am just doing something incredibly stupid or forgetting something stupid and will waste someone's time but I'm out of options and ideas at this point, so apologies if that ends up being the case. I'm not using Eclipse or Android Studio, just CLI Maven. I need to use the DrawerLayout in my app, but the app crashes when attempting to instantiate it due to not being able to find the class (and presumably the rest of the support-v4 package) at runtime. So, step by step.
Here's the line of code that creates the DrawerLayout:
DrawerLayout drawer = new android.support.v4.widget.DrawerLayout(this);
Here's the stack trace of how the app crashes when it tries to create a new instance of the DrawerLayout.
E/AndroidRuntime( 2065): FATAL EXCEPTION: main
E/AndroidRuntime( 2065): Process: com.patron.main, PID: 2065
E/AndroidRuntime( 2065): java.lang.NoClassDefFoundError: android.support.v4.widget.DrawerLayout
E/AndroidRuntime( 2065): at com.patron.main.FlashMenu.onCreate(FlashMenu.java:120)
E/AndroidRuntime( 2065): at android.app.Activity.performCreate(Activity.java:5933)
E/AndroidRuntime( 2065): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
E/AndroidRuntime( 2065): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
E/AndroidRuntime( 2065): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
E/AndroidRuntime( 2065): at android.app.ActivityThread.access$800(ActivityThread.java:144)
E/AndroidRuntime( 2065): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
E/AndroidRuntime( 2065): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 2065): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime( 2065): at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime( 2065): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 2065): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime( 2065): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime( 2065): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
W/ActivityManager( 1228): Force finishing activity com.patron.main/.FlashMenu
Here's how I'm including the dependency in my POM.xml:
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
<version>21.0.3</version>
<type>aar</type>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
I'm using the local maven repository provided by google in the android-sdk/extras/android/m2repository folder as suggested by another SO post. Obviously it can compile and run ok so I'm confident it's finding it properly. When I call mvn dependency:build-classpath to see the compile-time classpath, it shows me this:
And then manually opening that AAR folder in 7zip and checking the classes jar to ensure the DrawerLayout is in there, I can see it most certainly is:
So at this point I am unsure what I can change or do to get this support package available at runtime. I went over the classpath in detail and I am confident I am not importing the support-v4 package twice, just once, and judging by the nature of errors from importing it twice I don't think I'd be able to compile if that were the problem. I tried manually setting the scope of the dependency to compile (which should be the right one), then to runtime and provided just in case without any luck. If anyone has any ideas as to what the problem could be to solve this NoClassDefFoundError, it would be most appreciated.
Figured it out. For posterity:
You need to update to the latest version of the Android Maven Plugin, in order to avoid this error. In addition, an old bug I was running into where ActivityCompat21 was not being found along several other classes that I fixed with a hacky workaround is also fixed by updating to version 4.0.0-rc2 of the plugin.
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.0.0-rc.2</version>
<extensions>true</extensions>
<configuration>
<includeLibsJarsFromAar>true</includeLibsJarsFromAar>
</configuration>
</plugin>

Vitamio Sample Error - java.lang.UnsatisfiedLinkError: Couldn't load vinit findLibrary returned null

I'm having trouble running the vitamio-sample from https://github.com/yixia/VitamioBundle.
I am building it with Android Studio and it compiles fine and runs, but when it gets to this line:
if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this))
return;
It throws an exception when I run it on my Nexus 5 (and also on a Galaxy S4):
01-22 11:58:40.759 12323-12323/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: io.vov.vitamio.demo, PID: 12323
java.lang.UnsatisfiedLinkError: Couldn't load vinit from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/io.vov.vitamio.demo-1.apk"],nativeLibraryDirectories=[/data/app-lib/io.vov.vitamio.demo-1, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at io.vov.vitamio.Vitamio.<clinit>(Vitamio.java:258)
at io.vov.vitamio.LibsChecker.checkVitamioLibs(LibsChecker.java:40)
at io.vov.vitamio.demo.VitamioListActivity.onCreate(VitamioListActivity.java:40)
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)
The exception also happens when I'm running the v4.2.0 tree in my own app.
Any idea what I'm missing? In my own app I pulled the vitamio project into a libraries folder and am referencing it like this:
compile(project(':libraries:vitamio'))
The sample project is left as-is.
I am not sure if there is a cleaner way in the newer version of Vitamino (or gradle). But here is how I got it to work with gradle build tools 0.6.
Added a project to my /libraries directory with the vitamino source/sdk. This has a /libs/armeabi /libs/armeabi-v7a with libvinit.so inside.
In my build.gradle for my main project, reference the library project like:
dependencies {
// other dependencies
compile(project(':libraries:vitamio'))
}
Add the following to the bottom of my build.gradle
task copyNativeLibs(type: Copy) {
from(new File(project(':libraries:vitamio').getProjectDir(), 'libs')) { include '**/*.so' }
into new File(buildDir, 'native-libs')
}
tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs }
clean.dependsOn 'cleanCopyNativeLibs'
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
pkgTask.jniDir new File(buildDir, 'native-libs')
}
Then when i run a clean and rebuild it will copy the native libs to the proper spot and include them in the build.

NullPointerException in Android when declaring a Content Provider

I'm facing a strange issue when declaring a Content Provider in my project. I'm copying the classes and Manifest declaration from another project of my own. It's working OK on my other project.
Here's part of my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.qr"
android:installLocation="auto"
android:versionCode="540"
android:versionName="5.4" >
(...)
<application
android:name=".Application"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:logo="#drawable/ic_launch" >
(...)
<provider
android:name=".provider.HistoryProvider"
android:authorities="com.example.qr.History"
android:exported="true"
android:multiprocess="true"
android:readPermission="com.example.qr.History.read"
android:writePermission="com.example.qr.History.write" />
(...)
</application>
</manifest>
When I run my app, I get this stack trace:
FATAL EXCEPTION: main
java.lang.NullPointerException
at android.app.ActivityThread.installProvider(ActivityThread.java:4783)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4430)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4372)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
This is the whole stack trace. No 'com.example' trace is included. Of course some code in my app is producing this but the actual crash happens in Android.
Because my own classes are not included in the stack trace, I really don't know where to look.
I've run the code in an emulator with Android 4.2 and I've compared it with the source code of that version of Android, so I know the crash is produced in this line of ActivityThread:
4782 ApplicationInfo ai = info.applicationInfo;
4783 if (context.getPackageName().equals(ai.packageName)) {
Here's a link to the source code of this class.
If I don't declare the content provider (i.e. if I remove from my Manifest), the app works perfectly.
I've added some logs to my Application class, as well as the main Activity class. The crash is produced before either is launched.
So, my question is: what in my code can be producing context, context.getPackageName() or info.applicationInfo to be null during installation?
EDIT
When triggering the stack trace in the emulator several times, I only get this between traces:
09-11 23:10:21.250: E/AndroidRuntime(933): at dalvik.system.NativeStart.main(Native Method)
09-11 23:10:21.470: D/dalvikvm(933): GC_CONCURRENT freed 142K, 9% free 2951K/3224K, paused 78ms+3ms, total 225ms
09-11 23:10:44.030: I/Process(933): Sending signal. PID: 933 SIG: 9
09-11 23:10:46.940: D/dalvikvm(947): GC_CONCURRENT freed 164K, 10% free 2711K/2996K, paused 13ms+114ms, total 201ms
09-11 23:10:47.170: I/ActivityThread(947): Pub com.example.qr.History: com.example.qr.provider.HistoryProvider
09-11 23:10:47.170: D/AndroidRuntime(947): Shutting down VM
09-11 23:10:47.170: W/dalvikvm(947): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
09-11 23:10:47.180: E/AndroidRuntime(947): FATAL EXCEPTION: main

Categories