我能够创建一个新的 AndroidStudio 项目并将我的旧代码移植到其中。
但是现在我收到一些关于某些库(例如 Flurry)无法识别的编译错误。
请参阅此屏幕截图,其中对 Flurry 的引用为红色:
这就是我的旧 .jar 的样子:
我需要通过什么方式来移植 jar ?现在应该通过 Gradle 来处理吗?我该怎么做呢?现在我的 Gradle 文件如下所示:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "problemio.com.problemionew"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
我应该添加如下行:
compile 'com.android.support:acra-4.2.3'
compile 'com.android.support:android-support-v4'
compile 'com.android.support:FlurryAgent'
compile 'com.android.support:gcm-server'
compile 'com.android.support:gcm'
最佳答案
如果您想将 jar 添加到项目中,请将 jar 移至 libs
文件夹并在成绩文件中执行以下操作:
compile files 'your.jar.file.name.here.jar'
对于您要导入的每个 jar。
这应该可以解决问题。
文件夹看起来像:
然后依赖项 block 将类似于:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile files('libs/android_antlib_4-12-0.jar')
}
关于android - 将项目移植到 Android Studio 时如何使用旧的 .jar 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34302690/