Seriously, i don't know what to do to solve this problem.
My android project was working fine, until i needed to import a library with Maven. Since that, everything started to collapse.
What is happening: When i start my application, the following error appears on LogCat and android tells that my app stopped working. I've searched for this similar error here AND on the rest of the internet, but everything people did haven't worked for me.
Error:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.buscaserra/com.buscaserra.main.ActivitySplash}: java.lang.ClassNotFoundException: Didn't find class "com.buscaserra.main.ActivitySplash" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.buscaserra-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.buscaserra-2, /vendor/lib, /system/lib]]
Manifest and packages:
Build Path:
Same problem here.
What worked for me was adding android-support-v4.jar as a lib and making sure it was checked on Project properties -> Build Path -> Order & export.
It was mentioned here
I had the same problem when I moved the project folder from a Linux machine to a Mac.
What I did was:
Close the project
Remove the .iml file
Import the project using the "Create new project using existing code"
I am using IntelliJ.
Cheers.
I did the following steps to resolve the issue on Android Studio.
open file ./app/build.gradle
reduce compileSdkVersion (e.g. 22 -> 21)
click 'sync project with gradle file'
change back to the original compileSdkVersion (e.g. 22)
click 'sync project with gradle file'
recompile and it should work.
I have spent way to many hours on this stupid issue but finally got it resolved:
When creating a new project -> package name is causing this stupid dex issue to appear, must not be able to find the main activity during run time with whatever deployment assemply setup. Android Studio doesn't like some of my commonly used package names, I'm completely baffled..I think this is a pretty big bug haha
Given the following new project parameters:
Name: NotificationApp,
packageName: com.stores.business.notificationapp,
saveLocation: /home/me/AndroidStudioProjects/NotificationApp
I would get the following error:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.stores.business.notificationapp/com.stores.business.notificationapp.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.stores.business.notificationapp.MainActivity" on path: DexPathList[[zip file "/data/app/com.stores.business.notificationapp-2/base.apk"],nativeLibraryDirectories=[/data/app/com.cvs.stores.myapplication-2/lib/arm64, /vendor/lib64, /system/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
My Solution
I resolved it by changing the package name to:com.notificationapp, then File->invalidate caches/Restart..hope this helps someone else haha
Do you have any required projects on the build path? Can't tell from your screen shot but check your "Projects" tab. You may have inadvertently added a Project Library as a required project instead. Remove the project from the Projects tab and then project -> properties. Click Android, add the project as a library instead here...
Make sure that any compatibility lib jars that you're using in your main project (like android-support-v4.jar) are the same versions as those used in any of the projects that your main project references.
I had this same problem and what solved it was to copy and paste the android-support-v4.jar from another library project (that my main project was referencing) and pasting it into my main project's /libs folder.
I had the same issue.
Nothing had changed except Android studio and Gradle updated since I last compiled.
I took a look at the build options under Build>Edit Build Types and noticed that the one option that was different between my project that didn't run and the ones that did work was the Minify Enable option.
I set it to false and now everything works again.
I should understand the problem by just seeing "dex errors".But it took half day to fix the issue.
I fix this by following android developers page's instruction: https://developer.android.com/studio/build/multidex.html
First add this to my gradle.build:
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Then I extend my Application class (or declare the application class in AndroidManifest.xml or override attachBaseContext() function) as instructed by the MultiDexApplication class document on the page. This have fixed my problem.
Related
When adding firebase_auth to dependencies (pubspec.yaml) to my flutter project I'm getting this error:
The plugin firebase_auth doesn't have a main class defined in C:\Users(username)\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_auth-3.1.3\android\src\main\java\io\flutter\plugins\firebase\auth\FlutterFirebaseAuthPlugin.java or C:\Users(username)\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_auth-3.1.3\android\src\main\kotlin\io\flutter\plugins\firebase\auth\FlutterFirebaseAuthPlugin.kt. This is likely to due to an incorrect androidPackage: io.flutter.plugins.firebase.auth or mainClass entry in the plugin's pubspec.yaml.
If you are the author of this plugin, fix the androidPackage entry or move the main class to any of locations used above. Otherwise, please contact the author of this plugin and consider using a different plugin in the meanwhile.
My code is just the dummy code created by android studio and the only thing i added is firebase_auth: ^3.1.3 in pubsbec.yaml , the .json file in the android/app directory and registered the app on Firebase website.
I get the same issue in VS Code, so Android Studio is not the problem.
I would really appreciate any help!
Add the firebase_core pugin because it is essential and if you did everything according to the documentation then flutter clean after that pub cache repair will do the the work. then again run.
I think you haven't added Firebase core in your pubspec.yaml file. Try to add firebase_core 1.7.0 in your pubspec.yaml and then clean your project using this command flutter clean
also Checkout this installation guide
I'm strugling with using jackson-dataformat-xml on android
I have some very basic code that works fine on oracle jre
JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
XmlMapper xmlMapper = new XmlMapper(module);
First I tried official documentation adapted for gradle (by me, not sure if done correctly):
compile 'com.fasterxml.jackson.core:jackson-core:2.5.4'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.5.4'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.4'
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.5.4'
compile 'org.codehaus.woodstox:woodstox-core-asl:4.4.1'
compile 'javax.xml.stream:stax-api:1.0-2'
Result: gradle fails build time about bundling corelibraries into an application
...
:app:preDexDebug
trouble processing "javax/xml/stream/EventFilter.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
...
2nd attempt trying to follow Sean's answer
(Basicly he repackages corelibs with prefix names and rebuilds jackson-dataformat-xml to use the prefixed names)
compile 'com.fasterxml.jackson.core:jackson-core:2.1.2'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.1.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.1.2'
// Repackaged XML-specific libraries
compile 'edu.usf.cutr.android.xml:jackson-dataformat-xml-android:2.1.2'
compile 'edu.usf.cutr.android.xml:stax2-api-android:3.1.1'
compile 'edu.usf.cutr.android.xml:stax-api-android:1.0-2'
compile 'edu.usf.cutr.android.xml:aalto-xml-android:0.9.8'
And build time failed on duplicates
Duplicate files copied in APK META-INF/services/com.fasterxml.jackson.core.ObjectCodec
so added:
packagingOptions {
...
exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
exclude 'META-INF/services/com.fasterxml.jackson.core.ObjectCodec'
}
When adding the exclusions it builds and deploys, but fails runtime on below stackdump (AFAIK it cant find the SAX provider, even tho it is added to the classpath to my understanding)
edu.usf.cutr.javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.MXParserFactory not found
at edu.usf.cutr.javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
at edu.usf.cutr.javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
at edu.usf.cutr.javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
at edu.usf.cutr.javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136)
at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:97)
at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:85)
at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:82)
at com.fasterxml.jackson.dataformat.xml.XmlMapper.<init>(XmlMapper.java:46)
What is the proper way to move forward on either #1 or #2?
Number 2 is the correct approach (Android doesn't like it when you include classes in the official Java package namespace - but then again, I wrote the original answer so I'm biased ;) ).
I believe the FactoryConfigurationError: Provider com.bea.xml.stream.MXParserFactory not found error is due to a bug in the Android build tools. In previous versions of ADT for Eclipse and Gradle plugin < 0.7.0 the /META-INF/* files are stripped from the JARs during the build process. It seems like >= v0.7.0 shouldn't have the problem according to Google, but from others' reports it sounds like it still may be problematic, and could potentially remove the META-INF/services/javax.xml.stream.XMLInputFactory file, which is required for the platform to register Aalto.
Try the workaround mentioned in AOSP issue 59658 comment 22:
right click on /src/main (where you have /java and /res folders),
select New > Folder > Java Resources Folder,
click Finish (do not change Folder Location),
right click on new /resources folder,
select New > Directory
enter "META-INF" (without quotes),
right click on /resources/META-INF folder,
select New > Directory
enter "services" (without quotes)
copy any file you need into /resources/META-INF/services
For you, in step 10 above you'd need to copy this file into /resources/META-INF/services. In case the file link is broken in the future, the name of the file is javax.xml.stream.XMLInputFactory and it consists of a single line:
com.fasterxml.aalto.stax.InputFactoryImpl
EDIT
If you get a "Error:duplicate files during packaging of APK... Path in archive: META-INF/services/javax.xml.stream.XMLInputFactory", you can try telling Gradle to keep the first occurrence with:
android {
packagingOptions {
pickFirst 'META-INF/services/javax.xml.stream.XMLInputFactory'
}
}
EDIT 2
This bug may be affecting "pickFirst". Please make sure you're running the latest version of Android Studio, and update your local tools and Android Gradle plugin to make sure you're running the most recent version of the tools. This may be fixed in Android Studio 1.3 RC1.
I have attempted to add XmlPull support to jackson xml. Find the forked project here:
https://github.com/finvu/jackson-dataformat-xml
Currently, only supported for version 2.9.6. (clone the branch jackson-dataformat-xml-2.9.6-XmlPull)
Sorry, I am not able to provide detailed documentation due to time constraints. If you have knowledge of git and maven to pull a specific branch and build the jar, then it should be relatively easy.
To those who will be in need of this in the future:
first integrate Jitpack in Your Android app, following their instructions:
https://jitpack.io/
Then paste teh GitHub url of jackson-dataformat-xml on Jitpack sites' corresponding text box. GitHub url is:
https://github.com/FasterXML/jackson-dataformat-xml.
That's it! Enjoy the result. :)
Using IntelliJ 14.0.3, my Android project was working until I built the project few times after each other and BANG, it doesn't come up anymore and it throws an Runtime Exception:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.rahil.ecat/com.rahil.activity.Activity_Main}:
java.lang.ClassNotFoundException: Didn't find class
"com.rahil.activity.Activity_Main" on path:
DexPathList[[zip file "/data/app/com.rahil.ecat-1.apk"],
nativeLibraryDirectories=[/data/app-lib/com.rahil.ecat-1,
/vendor/lib, /system/lib]]
I've searched SO and found some answers which weren't for IntelliJ and they are all for Eclipse and I'm quite confused how to fix this and it's driving me crazy.
Any ideas?
Ok I figured it out myself, using intellij 14.0.3 follow the below:
settings -> Build, Exclusion, Deployment -> Compiler -> Excludes
then you have to remove the excluded class from the list.
Note: The excluded classes have a little 'x' near their class icons.
Since ADT update to revision 22 (May 2013) you have to check "Android Private Libraries" check box in
Project -> Properties -> Java Build Path -> Order and Export in Eclipse for your older projects to get rid of this exception ...
*THIS PART WAS MY ORIGINAL STARTING PROBLEM. PLEASE READ THE UPDATES
I have imported an android project in eclipse that apparently depends on rengwuxian.
Since I could not find the jar and did not know how else to do it, I followed the instructions in consuming-aars-eclipse and imported a second project with the artifacts from the aar as an android eclipse project as well.
Then in my original project that I got compilation errors for com.rengwuxian.materialedittext.MaterialEditText in my layout files I added this newly created from the aar project as a reference (Project->Properties->Build Path->Add Project)
The compilation errors got resolved! But in my layout files now everywhere that is defined the element com.rengwuxian.materialedittext.MaterialEditText I get errors in the resource definitions.
Eg.the following:
error: No resource identifier found for attribute 'baseColor' in
package 'com.test
The attibute it seems to complaint about is:
<com.rengwuxian.materialedittext.MaterialEditText
android:id="#+id/client"
android:layout_width="match_parent"
android:layout_height="wrap_content"
.....
android:textColor="#color/text_color"
app:baseColor="#color/text_color"
app:primaryColor="#color/text_color" />
---> app:baseColor="#color/text_color"
This #color/text_color is defined in my original application in the original application's package and apparently the classes in the aar imported project (com.rengwuxian.materialedittext.MaterialEditText) can not see/access these resources.
How can I fix this? Or is there another better way for my problem?
Note: I also tried adding a source link to the folder of my project's res/ folder but did not solve this.
Update:
I removed the reference to the project and add the classes.jar to the build path (this jar was inside the aar project). Same issue
UPDATE 2:
I found this that helps to import aars to eclipse aar-for-eclipse. I copy/pasted the code snippets (task copyJarDependencies etc) in the folder but I got an exception:
No such property: libDir for class: org.gradle.api.tasks.Copy_Decorated
So I added a def in the line `libDir = new File(project.projectDir, '/libs')
Then this worked but I got:
Could not find property 'compile' on configuration container
How can fix this? I am not sure what to declare or what is missing
Update 3:
I added apply plugin: 'java' and the compile attribute is ok now but I get:
configurations.releaseCompile.filter {it.name.endsWith 'jar'}.each { File file -> moveJarIntoLibs(file)}
How can I fix this so that it works?
I am using this project ---> https://github.com/rengwuxian/MaterialEditText
And this post ---> http://www.nodeclipse.org/projects/gradle/android/aar-for-Eclipse
I've got a similar problem with gradle but on android studio. Solution for me was to use
configurations.releaseCompile.filter {it.name.endsWith 'jar'}.each {moveJarIntoLibs(it)}
instead of:
configurations.releaseCompile.filter {it.name.endsWith 'jar'}.each { File file -> moveJarIntoLibs(file)}
And remember not to apply java and android plugin in the same project, because it won't work (see gradle with --debug --stacktrace )
I had a working android project but needed to start from scratch. I copied all my source files and layout files over. There are no compilation errors but when I try to run, I get the following error.
11-27 17:21:56.793: E/AndroidRuntime(1450): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{projects.mobile.mapappproject/projects.mobile.mapappproject.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "projects.mobile.mapappproject.MainActivity" on path: /data/app/projects.mobile.mapappproject-1.apk
I am running eclipse juno and trying to run on Android 4.2. Thanks !
Rather than doing copy paste try following
1.Create an android application project
2.Delete the files which was created Eg.MainActivity and layout.
2.Right click on project name and click import ,then from File system.Go to your project directory to import the source from there
3.select that, then finish.
4.Clean and build then run
Try these
Add the Activity to AndroidManifest.xml
Is there a difference in your folder names ? For example projects.mobile.mapappproject-1 or projects.mobile.mapappproject !
I copied all my source files and layout files over.
It looks like you forgot to copy over the entries that existed in AndroidManifest.xml, however. Each Activity has an entry there and that entry is required for the framework to find and launch the UI.
I had the same problem, but I found out that a library reference path wasn't right. After I fixed that everything worked fine.
You can check this at Right-click on your project => Properties => Android -> (Library)
Just for the record in case I can help someone :
I had a project that somehow didnt work after importing it from git. I solved this by giving the name of the activity explicitly.
example:
before:
<activity android:name=".Main" [...] /> (relative)
after: <activity android:name="com.example.package.Main" [...] /> (absolute)
This may also occur if you change the manifest package and keep your relative reference (which I think is default).
In my case, following 2 steps fixed the problem
a. Setting compileSdkVersion, buildToolsVersion, targetSdkVersion to the same SDK version in build.gradle.
b. I was missing a dot in application class name in AndroidManifest.xml (Ex. android:name=".ui.ApplicationLoader")