问题
How can I import widgets library in this github link to my project??? https://github.com/tobykurien/BatteryFu
I tried a way but faced with this error while run :
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.8.0_51\bin\java.exe'' finished with non-zero exit value 2
回答1:
Please follow below steps :
- Click on File -> New -> Import New Module.
- Add Souce Directory path as library root level path.
- Click 'OK' and 'Finish'.
- Go to project setting -> Widget -> dependencies -> click in '+' -> add module ->add widget here.
- Now open Widget module libs folder and remove your support-v4 jar file.
- Remove 'compile fileTree(dir: 'libs', include: ['*.jar'])' from Widget gradle file.
- Go to project setting -> Widget -> dependencies -> click in '+' -> add library ->add support v4 here.
- Open Manifest.xml of widget module.
- Change minSDk to '4'
Now build your project and run.And if you found any error let me know.
Your Widget gradle file should look like :
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 18
buildToolsVersion "19.1"
dependencies {
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
aidl.srcDirs = ['src']
java.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.2.1'
}
Manifest.xml of Widget should look like :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.koushikdutta.widgets"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="10" />
<application
android:allowBackup="true">
</application>
</manifest>
来源:https://stackoverflow.com/questions/32117325/how-to-import-this-library-to-android-studio