Error while using jar file in android studio - android

I am new to android. I am doing one project in that i want to use jar file. Actually I converted .apk file to .jar file by using dex2jar. I added that .jar file in lib folder and added as library. but when running the app it shows an error:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
and my build.gradle file is
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.protocolnet.myapplication"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile files('libs/viabee-dex2jar.jar')
}
.
How to get rid from that error. Please anybody help me?

You can't use .jar file converted from apk as a Library because of that it is not Library. You can get source code using this method.

Related

My Android project Build Failed and never execute the project?

My question is, I was try to change the package name of my android project, when I build my project it's give me error, And then I pressed ctrl+z button to rewrite my package name before and try to built it again it's not build my project.
my error is
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\DELL\Documents\adt-bundle-windows-x86-20140702\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1
First you see the screen shot
now you see my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "app.tabsample"
minSdkVersion 15
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.1.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-ads:8.3.0'
}
I have a latest build version
classpath 'com.android.tools.build:gradle:1.3.0'
and also I tried to clean and rebuild the project and also I tried to restart the Android studio but the error not goes. It's my complete whole project.
As written in the first error, you have a space which is an invalid character in the category tag it should be <category android:name=android.intent.category.default/>.

Execution failed for task app:compileDebugAidl: aidl.exe finished with non-zero exit value 3

I am trying to build my project with AIDL example. But I keep getting this error:
:app:compileDebugAidl
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid
Error:Execution failed for task ':app:compileDebugAidl'.
> com.android.ide.common.process.ProcessException:org.gradle.process.
internal.ExecException:
Process 'command 'C:\Users\xuefu\AppData\Local\Android\sdk\build-tools\23.0.1\aidl.exe''
finished with non-zero exit value 3
Information:BUILD FAILED
below is my build file and I am using Android Studio 1.3.2, Gradle 1.3.0 under the windows 8.1 x64 platform:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "org.crazyit.service"
minSdkVersion 10
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
}
Please check your aidl files, make sure all the files include the package name. e.g.
package com.zebra.gogogo;
parcelable GoInfo;

UNEXPECTED TOP-LEVEL EXCEPTION : DexIndexOverflowException while running the app on Android studio

I am using google play services version 7.5.0 and getting below mentioned error while running a project.
My project contains 2 modules.
Here are the build.gradle file of each modules.
Module 1:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
}
Module 2:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':module1')
}
And here is build.gradle file of app
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "com.vserv.offerwall"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
dexOptions {
jumboMode true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':module2')
}
repositories {
flatDir {
dirs 'libs'
}
}
When I am building the app, it get build successfully. But when I am trying to run the app, I am getting below mentioned error.
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_45\bin\java.exe'' finished with non-zero exit value 2
I have done some Google and found below mentioned link.
Unable to execute dex: method ID not in [0, 0xffff]: 65536
I have tried this and edited the app gradle file by adding multiDexEnabled true into defaultConfig and compile 'com.android.support:multidex:1.0.0' in dependencies.
After that the above mentioned error is resolved and then I got another error while running the app.
:app:shrinkDebugMultiDexComponents FAILED
Error:Execution failed for task ':app:shrinkDebugMultiDexComponents'.
java.io.IOException: Can't read [D:\StudioWorkspace\SampleSDKDemoProject\app\build\intermediates\multi-dex\debug\allclasses.jar] (Can't process class [org/fmod/FMODAudioDevice.class] (256))
Kindly help me to solve this.
Thanks in advance.
Instead of importing ALL modules from google services
compile 'com.google.android.gms:play-services:7.5.0'
Import only the modules you need. Check this page.
Note: If the number of method references in your app exceeds the 65K
limit, your app may fail to compile. You may be able to mitigate this
problem when compiling your app by specifying only the specific Google
Play services APIs your app uses, instead of all of them.

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'

I am getting an ':app:packageAllDebugClassesForMultiDex' Error when I try to build an application using the YouTubeData API. I have researched several other threads that cover this error and the conclusion that I have come to is that I have libraries in my build file that are creating a duplicated reference to build files. I know that the file triggering the error is:
'com/google/api/client/googleapis/json/GoogleJsonErrorContainer.class'
but how do I exclude the reference from the build file with out removing the entire library?
This is my build file
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "co.hannalupi.fitnessblenderapp"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.apis:google-api-services-youtube:v3-rev136-1.20.0'
}
This is the error I get:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/api/client/googleapis/json/GoogleJsonErrorContainer.class
I am new to Android, any direction you can point me in would be greatly appreciated. Thanks in advance.
An update for folks having a similar error - As a last resort I deleted the project file that I was working in from my desktop and cloned a fresh copy from GitHub. Importing and running the fresh copy gave me no errors!!

zipalign.exe'' finished with non-zero exit value

I'm a student programmer and I'm continuing an Android project that has been previously started by other students before me. My problem is that I'm getting an error when I try to execute the Android app inside Android Studio. You can see the error message below. The compilation must have worked for the other students since I have an apk file. What's wrong with zipalign?
:app:zipalignDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:zipalignDebug'.
> Process 'command 'X:\Sdk Android Studio\build-tools\21.1.2\zipalign.exe''
finished with non-zero exit value -1073741502
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "csf.dfc.friendtracker"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/guava-18.0.jar')
compile files('libs/Pubnub-Android-3.7.2.jar')
compile files('libs/mysql-connector-java-5.1.34-bin.jar')
}
EDIT:
I haven't found the cause of the error but I added all the project objects in a new one and the error disappeared.
Remove the apk file in the Deploy directory and the export worked fine then.
I realized this happen when you have the directory "..\app\build\outputs\apk\" open in your Windows Explorer. You just need to close it and rebuild the project.
This happened to me too, when I tried to generate the apk in the following path:
C:\users\desktop
Change your signed generated apk destination path used to generate to the following:
<your project path>\app\build\outputs\apk
Example:
E:\androidStudio\CountDownTimer\app\build\outputs\apk

Categories

Resources