编译Android Gallery图库源码所遇bug

转载请注明出处: http://blog.csdn.net/lb377463323/article/details/68936291

1. selectiveAdjust() isnot supported in SDK levels 11-15

Error:(99, 32) error: Non-root compute kernel selectiveAdjust() is not supported in SDK levels 11-15
F:\Apps\GalleryActivity\app\src\main\rs\grad.rs
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]

在清单文件中设置minSdkVersion大于15即可

2. ScriptC_grad cannot be resolved to a type

Description Resource Path Location Type
ScriptC_grad cannot be resolved to a type ImageFilterGrad.java /GalleryActivity/src/com/android/gallery3d/filtershow/filters line 146 Java Problem

这是Eclipse的Android Dependencies找不到renderscript-v8.jar这个包,或者这个包的版本不对。

如果是找不到这个包的话,右键项目名 -> 点击Properties ->Java Build Path -> Libraries -> Add External JARs。

如果是包版本不对的话,打开project.properties文件,设置sdk.buildtools为正确版本即可,如sdk.buildtools=25.0.2。如果不在此处设置的话会默认使用sdk中Build-Tools的最高版本,你把版本过高的Build-Tools卸载掉也行。

3. AndroidStudio找不到RenderScript

在AndroidStudio中使用V8包中的RenderScript,只需要修改项目的build.gradle中的代码即可

android {
     ...
     defaultConfig {
          ...
          renderscriptTargetApi 18
          renderscriptSupportModeEnabled true
     }
     ...
}
4. Duplicate files copied in APK META-INF/DEPENDENCIES

Error:Execution failed for task ‘:app:transformResourcesWithMergeJavaResForDebug’.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/DEPENDENCIES
File1: F:\Apps\GalleryActivity\app\libs\httpclient-4.5.3.jar
File2: F:\Apps\GalleryActivity\app\libs\httpcore-4.4.6.jar

这是因为两个包里面有文件重复了, 打开项目下面的 build.gradle 文件,在 android 代码块中添加下面代码,排除掉重复文件

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/MANIFEXT.MF'
}
5. Your project contains C++ files but it is not using a supported native build system

Error:Execution failed for task ‘:app:compileDebugNdk’.
Error: Your project contains C++ files but it is not using a supported native build system.
Consider using CMake or ndk-build integration with the stable Android Gradle plugin:
https://developer.android.com/studio/projects/add-native-code.html
or use the experimental plugin:
https://developer.android.com/studio/build/experimental-plugin.html.

首先在工程目录下的gradle.properties文件的末尾加上一句(如果没有gradle.properties文件 ,自己拷一份进来):
Android.useDeprecatedNdk=true
然后再在文件build.gradle(Module:app)里面的buildTypes类中添加一个这样的方法

sourceSets {
main {
jni.srcDirs = []
}
}

6. INSTALL_FAILED_CONFLICTING_PROVIDER

Installation failed with message Failed to finalize session : INSTALL_FAILED_CONFLICTING_PROVIDER: Package couldn’t be installed in /data/app/com.android.gallery3d-1: Can’t install because provider name com.android.gallery3d.provider (in package com.android.gallery3d) is already used by com.vivo.gallery.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.

把清单文件里面的provider的android:authorities改成别的名字,我这里是在最后加1

<provider android:name="com.android.gallery3d.provider.GalleryProvider"
        android:syncable="false"
        android:grantUriPermissions="true"
        android:exported="true"
        android:permission="com.android.gallery3d.permission.GALLERY_PROVIDER1"
        android:authorities="com.android.gallery3d.provider1" />

如果出现INSTALL_FAILED_DUPLICATE_PERMISSION这个错误,就把清单文件的自定义permission的name改掉

<permission android:name="com.android.gallery3d.permission.GALLERY_PROVIDER1"
        android:protectionLevel="signatureOrSystem" />

<uses-permission android:name="com.android.gallery3d.permission.GALLERY_PROVIDER1" />

还有一种情况:手机一卸载冲突的那个APP,但是还是提示此错误,这可能是卸载不干净。
在终端中使用adb卸载即可: adb uninstall 包名

7. http:// schemas.android.com/apk/res-auto

Error:(19) Error: In Gradle projects, always use http://schemas.android.com/apk/res-auto for custom attributes [ResAuto]

将eclipse中
http://schemas.android.com/apk/res/com.xxx.xxx

换成
http://schemas.android.com/apk/res-auto

8,Gradle DSL method not found: ‘android()’

Error:(16, 0) Gradle DSL method not found: ‘android()’
Possible causes:

删除项目根目录build.gradle里面的android标签,如下图整个框内都删除,然后重新编译

9, NDK integration is deprecated in the current plugin

Error:(14, 0) Error: NDK integration is deprecated in the current plugin. Consider trying the new experimental plugin. For details, see http://tools.android.com/tech-docs/new-build-system/gradle-experimental. Set “android.useDeprecatedNdk=true” in gradle.properties to continue using the current NDK integration.
Open File

在gradle.properties文件中添加android.useDeprecatedNdk=true

注意大小写不可错

10,找不到符号

如果出现类似以下的错误:

Error:(95, 45) 错误: 找不到符号 符号: 变量 FORMAT_DNG 位置: 类 MtpConstants

检查build.tools版本,很大可能是因为build.tools版本太低了

11, java.lang.ClassNotFoundException,Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

如果遇到Android Studio直接run可以运行APP,但是Build APK生成的不能运行,出现上述报错信息,很大可能是因为Instant Run导致的,把它禁掉再重新生成apk就行了。

Android Studio –> File –> Setting –> Build, execution, deploy –> Instant Run.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值