我知道这很奇怪,但是可能自从我更新了Google Play服务之后,当我尝试使用像这样的意图从图库中获取图像时:
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
我的应用程序永远死机,无论选择图像还是取消意图操作,我都会黑屏,并确保我已将gradle文件还原回去,然后一切正常!
我的旧gradle文件
apply plugin: 'android'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 14
targetSdkVersion 23
versionCode 8
versionName "3.0.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
buildConfigField "boolean", "USE_CRASHLYTICS", "false"
ext.enableCrashlytics = false
}
}
lintOptions {
checkReleaseBuilds false
//abortOnError false
}
productFlavors {
}
}
dependencies {
compile project(':viewPagerIndicatorLibrary')
compile files('libs/universal-image-loader-1.9.1-with-sources.jar')
compile files('libs/httpclient-4.3.2.jar')
compile files('libs/httpclient-cache-4.3.2.jar')
compile files('libs/httpcore-4.3.1.jar')
compile files('libs/httpmime-4.3.2.jar')
compile files('libs/gcm.jar')
compile files('libs/jsoup-1.7.3.jar')
compile files('libs/PdfViewer.jar')
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:percent:+'
// compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
// compile "com.squareup.retrofit2:converter-gson:2.0.0-beta3"
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.guava:guava-collections:r03'
testCompile 'junit:junit:4.12'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.koushikdutta.ion:ion:2.+'
}
更新我的gradle文件后
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 14
targetSdkVersion 23
versionCode 8
versionName "3.0.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
buildConfigField "boolean", "USE_CRASHLYTICS", "false"
ext.enableCrashlytics = false
}
}
lintOptions {
checkReleaseBuilds false
//abortOnError false
}
productFlavors {
}
}
dependencies {
compile project(':viewPagerIndicatorLibrary')
compile files('libs/universal-image-loader-1.9.1-with-sources.jar')
compile files('libs/httpclient-4.3.2.jar')
compile files('libs/httpclient-cache-4.3.2.jar')
compile files('libs/httpcore-4.3.1.jar')
compile files('libs/httpmime-4.3.2.jar')
compile files('libs/gcm.jar')
compile files('libs/jsoup-1.7.3.jar')
compile files('libs/PdfViewer.jar')
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:percent:+'
// compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
// compile "com.squareup.retrofit2:converter-gson:2.0.0-beta3"
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:2.4'
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.guava:guava-collections:r03'
testCompile 'junit:junit:4.12'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.koushikdutta.ion:ion:2.+'
}
apply plugin: 'com.google.gms.google-services'
至于gradle项目文件,我只更改了此
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.google.gms:google-services:1.5.0-beta2'
classpath 'io.fabric.tools:gradle:1.+'
}
对此:
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.+'
classpath 'io.fabric.tools:gradle:1.+'
}
我知道这显然与画廊的意图无关,但实际上发生了什么。
在logcat中也没有什么值得注意的东西来定义问题,该应用程序只是冻结了!
最佳答案
我只使用了我需要的来自播放服务的库,如下所示:
compile 'com.google.android.gms:play-services-gcm:9.0.2'
compile 'com.google.android.gms:play-services-maps:9.0.2'
这解决了我的问题,但仍然需要Google对此问题进行解释和调查。
关于android - 从Google Gallery获取图片的Android在更新Google Play服务后卡住了应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37729223/