我将 com.android.support:support-v4 升级到 23.2.1,因为从 Android 6.0 开始,我们需要在运行时检查并请求权限。升级后,所有这些错误消息都会出现
错误:(48, 31) 错误:包 android.support.v4.view 不存在 android.support.v4.view.PagerAdapter 不存在。
因此,当我将旧的 android 支持 jar 文件添加回我的项目 libs 文件夹时,
ActivityCompat.requestPermissions 无法解决。
compile files('libs/android-support-v4.jar')
我尝试了几种解决方案,但仍然无法正常工作。是否有任何解决方法可以支持所有解决方案?
这是我的 gradle 文件。
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId ""
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
versionCode 117
versionName 'P.5.53.4'
}
signingConfigs {
release {
storeFile file("something.keystore")
storePassword "1234"
keyAlias "something"
keyPassword "1234"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
lintOptions {
// set to true to turn off analysis progress reporting by lint
quiet true
// if true, stop the gradle build if errors are found
abortOnError false
// if true, only report errors
ignoreWarnings true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/ASL2.0'
}
configurations {
all*.exclude module: 'servlet-api'
all*.exclude group: 'com.google.gson', module: 'gson'
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
buildTypes {
release {
}
}
dexOptions {
javaMaxHeapSize "4g"
}
repositories{
mavenCentral()
}
}
dependencies {
compile files('libs/aspectjrt.jar')
compile files('libs/CWAC-SackOfViewsAdapter.jar')
compile files('libs/httpclient-4.3.3.jar')
compile files('libs/httpcore-4.3.2.jar')
compile files('libs/httpmime-4.3.3.jar')
compile files('libs/jackson-core-asl-1.6.2.jar')
compile files('libs/jackson-mapper-asl-1.6.2.jar')
compile files('libs/universal-image-loader-1.9.1.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.android.support:multidex:1.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile project(':volley')
compile project(':lib')
compile 'com.google.android.gms:play-services:4.3.23'
compile 'com.newrelic.agent.android:android-agent:5.5.0'
compile 'com.google.zxing:core:3.2.1'
compile 'com.opencsv:opencsv:3.7'
compile "com.android.support:support-v4:23.2.1"
compile "com.android.support:support-v13:23.1.0"
compile "com.android.support:cardview-v7:23.1.0"
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:support-v4:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
//compile files('libs/android-support-v4.jar')
}
allprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}