ç¸ä¿¡å¾å¤æåå¨ä½¿ç¨Android studioå¼åä¸ï¼éå°è¿å¦ä½å¼å
¥ç¬¬ä¸æ¹soæ件çé®é¢ï¼ç¶è第ä¸æ¹å®æ¹ä»
ä»
ç»åºäºADTç¯å¢ä¸çéææ¹å¼ã
Android studioä¸é»è®¤ä½¿ç¨çæ¯gradleç¼è¯æ¹å¼ï¼ä¸ADTç¼è¾æ¹å¼ä¸ä¸æ ·ï¼é£ä¹soæ件åºå½å¦ä½å¼å
¥å¢ï¼
å
¶å®å¾ç®åãè¿é以éæJPUSH为ä¾ï¼çä¸ä¸soæ件å¦ä½å¼å
¥å°ç¼è¯ç¯å¢ï¼æç»å°JNIç´æ¥å¯ä»¥è°ç¨è¯¥soæ件ã
é¦å
ï¼å¨æ们çModuleçæ ¹ç®å½ä¸å»ºç«libsç®å½ï¼å°jpushéæSDKä¸çsoæ件åå«æ·å
¥ï¼æªå¾å¦ä¸ï¼
ç¶åå°±æ¯ç¼åæ们çbuild.gradleæ件ã
å
³äºsoæ件å¼å
¥çé
ç½®å¾ç®åï¼ä»£ç é
ç½®å¦ä¸ï¼
task nativeLibsToJar(type: Zip, description: "create a jar archive of the native libs") {
destinationDir file("$projectDir/libs")
baseName "Native_Libs2"
extension "jar"
from fileTree(dir: "libs", include: "**/*.so")
into "lib"
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn(nativeLibsToJar)
}
èªå®ä¹ä¸ä¸ªä»»å¡ï¼å¨å
¶ä¸æå®é¡¹ç®æä¾èµçsoæ件çç®å½ï¼è¿éç¨äº**/*.soæ¥åï¼ä¸ºäºçäºï¼æå®éè¦æ·å
¥çç®å½ into "lib"ï¼é£ä¹å¨æè¿è¡åºå°±è¢«æ·å
¥å°libç®å½ä¸ã
å®æ´çbuild.gradleæ件å¦ä¸ï¼
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.wujay.footerballstar"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
task nativeLibsToJar(type: Zip, description: "create a jar archive of the native libs") {
destinationDir file("$projectDir/libs")
baseName "Native_Libs2"
extension "jar"
from fileTree(dir: "libs", include: "**/*.so")
into "lib"
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn(nativeLibsToJar)
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
compile files('libs/jpush-sdk-release1.7.2.jar')
compile files('libs/umeng_sdk.jar')
compile files('libs/libammsdk.jar')
}
温馨提示:答案为网友推荐,仅供参考