Android 引用 build.xml 和 proguard 文件的构建错误:“返回空值:1”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23753320/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:24:34  来源:igfitidea点击:

Build error referencing build.xml and proguard file: "null returned: 1"

androidcordovaproguardbuild.xml

提问by brain56

While building my PhoneGap app (with the Facebook SDK plugin installed), I encountered this error:

在构建我的 PhoneGap 应用程序(安装了 Facebook SDK 插件)时,我遇到了这个错误:

BUILD FAILED C:\adt-bundle-windows-x86_64-20130522\sdk\tools\ant\build.xml:653: The following error occured while executing this line: C:\adt-bundle-windows-x86_64-20130522\sdk\tools\ant\build.xml:698: null returned: 1

BUILD FAILED C:\adt-bundle-windows-x86_64-20130522\sdk\tools\ant\build.xml:653: 执行此行时出现以下错误:C:\adt-bundle-windows-x86_64-20130522\sdk \tools\ant\build.xml:698:返回空值:1

Line 653 is:

第 653 行是:

<do-only-if-manifest-hasCode elseText="hasCode = false. Skipp aidl/renderscript/R.java">

Line 698 is:

第 698 行是:

proguardFile="${out.absolute.dir}/proguard.txt"

My solutions so far include the following:

到目前为止,我的解决方案包括:

  1. Ran android update projectto force generation of the proguard-project.txtfile, as well as update the local.propertiesand project.propertiesfile.
  2. Edited C:\adt-bundle-windows-x86_64-20130522\sdk\tools\ant\build.xmlso that all mentions to proguard.txtbecome proguard-project.txt.
  3. ran ant -logfile ./antLogFile.txt release. Here is the log file.
  1. Ranandroid update project强制生成proguard-project.txt文件,以及更新local.propertiesproject.properties文件。
  2. 编辑C:\adt-bundle-windows-x86_64-20130522\sdk\tools\ant\build.xml使所有提及proguard.txt变为proguard-project.txt.
  3. 跑了ant -logfile ./antLogFile.txt release。这是日志文件。

-set-mode-check:

-set-release-mode:

-release-obfuscation-check: [echo] proguard.config is C:\adt-bundle-windows-x86_64-20130522\sdk/tools/proguard/proguard-android.txt:proguard-project.txt [echo] Proguard.config is enabled

-pre-build:

-check-env: [checkenv] Android SDK Tools Revision 22.6.2 [checkenv] Installed at C:\adt-bundle-windows-x86_64-20130522\sdk

-setup: [echo] Project Name: HelloWorld [gettype] Project Type: Application

-build-setup: [getbuildtools] Using latest Build Tools: 19.0.3 [echo] Resolving Build Target for HelloWorld... [gettarget] Project Target: Android 2.3.3 [gettarget] API level: 10 [gettarget] WARNING: Attribute minSdkVersion in AndroidManifest.xml (14) is higher than the project target API level (10) [echo] ---------- [echo] Creating output directories if needed... [echo] ---------- [echo] Resolving Dependencies for HelloWorld... [dependency] Library dependencies: [dependency] [dependency] ------------------ [dependency] Ordered libraries: [dependency] [dependency] ------------------ [dependency] API<=15: Adding annotations.jar to the classpath. [echo] ---------- [echo] Building Libraries with 'release'...

nodeps:

-set-mode-check:

-set-release-mode:

-release-obfuscation-check: [echo] proguard.config is C:\adt-bundle-windows-x86_64-20130522\sdk/tools/proguard/proguard-android.txt:proguard-project.txt [echo] Proguard.config is enabled

-pre-build:

-check-env: [checkenv] Android SDK Tools Revision 22.6.2 [checkenv] Installed at C:\adt-bundle-windows-x86_64-20130522\sdk

-setup: [echo] Project Name: facebook [gettype] Project Type: Android Library

-build-setup: [getbuildtools] Using latest Build Tools: 19.0.3 [echo] Resolving Build Target for facebook... [gettarget] Project Target: Android 2.3.3 [gettarget] API level: 10 [echo] ---------- [echo] Creating output directories if needed... [mkdir] Created dir: C:\Users\brian.lee\Desktop\Eclipse Workspace\chumba_connect_trunk_new\facebook-android-sdk-3.14.1\facebook\bin\rsObj [mkdir] Created dir: C:\Users\brian.lee\Desktop\Eclipse Workspace\chumba_connect_trunk_new\facebook-android-sdk-3.14.1\facebook\bin\rsLibs [echo] ---------- [echo] Resolving Dependencies for facebook... [dependency] Library dependencies: [dependency] No Libraries [dependency] [dependency] ------------------ [dependency] API<=15: Adding annotations.jar to the classpath.

-code-gen: [mergemanifest] Found Deleted Target File [mergemanifest] Merging AndroidManifest files into one. [mergemanifest] Manifest merger disabled. Using project manifest only. [echo] Handling aidl files... [aidl] No AIDL files to compile. [echo] ---------- [echo] Handling RenderScript files... [echo] ---------- [echo] Handling Resources... [aapt] Generating resource IDs... [aapt] invalid resource directory name: C:\Users\brian.lee\Desktop\Eclipse Workspace\chumba_connect_trunk_new\facebook-android-sdk-3.14.1\facebook\bin\res/crunch

BUILD FAILED C:\adt-bundle-windows-x86_64-20130522\sdk\tools\ant\build.xml:601: The following error occurred while executing this line: C:\adt-bundle-windows-x86_64-20130522\sdk\tools\ant\build.xml:653: The following error occurred while executing this line: C:\adt-bundle-windows-x86_64-20130522\sdk\tools\ant\build.xml:698: null returned: 1

Total time: 2 seconds

-设置模式检查:

-设置释放模式:

-release-obfuscation-check: [echo] proguard.config 是 C:\adt-bundle-windows-x86_64-20130522\sdk/tools/proguard/proguard-android.txt:proguard-project.txt [echo] Proguard.config已启用

- 预构建:

-check-env: [checkenv] Android SDK Tools Revision 22.6.2 [checkenv] 安装在 C:\adt-bundle-windows-x86_64-20130522\sdk

-setup: [echo] 项目名称:HelloWorld [gettype] 项目类型:应用程序

-build-setup:[getbuildtools] 使用最新的构建工具:19.0.3 [echo] 解决 HelloWorld 的构建目标... [gettarget] 项目目标:Android 2.3.3 [gettarget] API 级别:10 [gettarget] 警告:属性AndroidManifest.xml 中的 minSdkVersion (14) 高于项目目标 API 级别 (10) [echo] ---------- [echo] 根据需要创建输出目录... [echo] ---- ------ [echo] 解析HelloWorld 的依赖... [dependency] 库依赖: [dependency] [dependency] ------------------ [dependency] 有序库:[dependency] [dependency] ------------------ [dependency] API<=15:将 annotations.jar 添加到类路径。[echo] ---------- [echo] 使用“release”构建库...

节点:

-设置模式检查:

-设置释放模式:

-release-obfuscation-check: [echo] proguard.config 是 C:\adt-bundle-windows-x86_64-20130522\sdk/tools/proguard/proguard-android.txt:proguard-project.txt [echo] Proguard.config已启用

- 预构建:

-check-env: [checkenv] Android SDK Tools Revision 22.6.2 [checkenv] 安装在 C:\adt-bundle-windows-x86_64-20130522\sdk

-setup: [echo] 项目名称:facebook [gettype] 项目类型:Android 库

-build-setup:[getbuildtools] 使用最新的构建工具:19.0.3 [echo] 为 facebook 解析构建目标... [gettarget] 项目目标:Android 2.3.3 [gettarget] API 级别:10 [echo] --- ------- [echo] 根据需要创建输出目录... [mkdir] 创建的目录:C:\Users\brian.lee\Desktop\Eclipse Workspace\chumba_connect_trunk_new\facebook-android-sdk-3.14.1\ facebook\bin\rsObj [mkdir] 创建的目录:C:\Users\brian.lee\Desktop\Eclipse Workspace\chumba_connect_trunk_new\facebook-android-sdk-3.14.1\facebook\bin\rsLibs [echo] ----- ----- [echo] 解决facebook的依赖... [依赖] 库依赖:[依赖] 没有库[依赖] [依赖] ------------------ [依赖] API<=15:将 annotations.jar 添加到类路径。

-code-gen: [mergemanifest] 找到已删除的目标文件 [mergemanifest] 将 AndroidManifest 文件合并为一个。[mergemanifest] 已禁用清单合并。仅使用项目清单。[echo] 处理 aidl 文件... [aidl] 没有要编译的 AIDL 文件。[echo] ---------- [echo] 处理 RenderScript 文件... [echo] ---------- [echo] 处理资源... [aapt] 生成资源 ID。 .. [aapt] 无效的资源目录名称:C:\Users\brian.lee\Desktop\Eclipse Workspace\chumba_connect_trunk_new\facebook-android-sdk-3.14.1\facebook\bin\res/crunch

构建失败 C:\adt-bundle-windows-x86_64-20130522\sdk\tools\ant\build.xml:601: 执行此行时出现以下错误:C:\adt-bundle-windows-x86_64-20130522\sdk \tools\ant\build.xml:653: 执行此行时出现以下错误:C:\adt-bundle-windows-x86_64-20130522\sdk\tools\ant\build.xml:698: null返回:1

总时间:2秒

All of my attempts yielded no progress. Why does this error occur? What must I do to build successfully?

我所有的尝试都没有取得任何进展。为什么会出现这个错误?我必须做什么才能成功构建?

回答by brain56

Close Eclipse and then run ant cleanin your project folder.

关闭 Eclipse,然后ant clean在您的项目文件夹中运行。

回答by ekerner

For me: I had

对我来说:我有

edited my config.xml wrongly

错误地编辑了我的 config.xml

. Try undoing your edits or placing a generic config.xml then see if she builds.

. 尝试撤消您的编辑或放置一个通用的 config.xml,然后查看她是否构建。

回答by EliuX

Verify your JAVA_HOMEvariable is correctly set to some path like C:\Program Files\Java\jdk1.7.0_67\and if the error still goes on, it may be solved going to the build.xmland setting trueto the variable fork, or the passed variable ${need.javac.fork}, which sets fork′s value in:

验证您的JAVA_HOME变量是否正确设置为某些路径C:\Program Files\Java\jdk1.7.0_67\,如果错误仍然存​​在,则可以转到build.xml并将其设置为true来解决该变量fork或传递的变量${need.javac.fork},这将fork的值设置为:

fork="${need.javac.fork}"

fork="${need.javac.fork}"

回答by gregko

For me, conflicting build targets were at fault. Needed to change project.properties in my library directory (which was appcompat) to 'target=android-21', instead of android-19 which I had before. If you encounter a similar error and the previous answer (ant clean) does not work, check all the build targets.

对我来说,冲突的构建目标是错误的。需要将我的库目录(appcompat)中的 project.properties 更改为“target=android-21”,而不是我之前使用的 android-19。如果您遇到类似的错误并且之前的答案 (ant clean) 不起作用,请检查所有构建目标。

回答by Lothre1

In order to determine if the problem comes from your development environment or from a mistake in the project i recommend everybody to try to create a new project from the cordova CLI.

为了确定问题是来自您的开发环境还是来自项目中的错误,我建议大家尝试从cordova CLI 创建一个新项目。

  • Open terminal
  • Type cordova create foo; cd foo;
  • Type cordova platform add android
  • Type cordova build
  • 打开终端
  • 类型 cordova create foo; cd foo;
  • 类型 cordova platform add android
  • 类型 cordova build

Does it works? So the problem is on your project configuration. This was my mistake: In order to add icons to the application I've create a folder called android inside `foo/plataforms/android/res/{android/icon*.png}

它有效吗?所以问题出在你的项目配置上。这是我的错误:为了向应用程序添加图标,我在 `foo/plataforms/android/res/{android/icon*.png} 中创建了一个名为 android 的文件夹

The correct way to add icons is to create the folder res in root of the project foo/{res/android/icon*.png}

添加图标的正确方法是在项目的根目录下创建文件夹res foo/{res/android/icon*.png}

And then, add this files into the configuration file as follows:

然后,将此文件添加到配置文件中,如下所示:

<platform name="android">
              <icon src="res/android/[email protected]" density="ldpi" />
              <icon src="res/android/[email protected]" density="mdpi" />
              <icon src="res/android/[email protected]" density="hdpi" />
              <icon src="res/android/[email protected]" density="xhdpi" />
     </platform>

回答by R.A. Lucas

You may also want to make sure your local.properties has the path to your sdk: sdk.dir=/path/to/adt/sdk

您可能还想确保您的 local.properties 具有您的 sdk 的路径: sdk.dir=/path/to/adt/sdk

回答by Malak Elzagadani

I had the same issue, I solved it this way:

我有同样的问题,我是这样解决的:

Go to the framework directory in the project, and type these commands to build the jar file (you will need to have antinstalled to generate the jar file, but it should be on your system already):

转到项目中的框架目录,并键入以下命令来构建 jar 文件(您需要ant安装以生成 jar 文件,但它应该已经在您的系统上):

android update project -p . -t android-23

ant jar

So just make sure what type of android you have because you may have tried android-19.

所以只要确定你有什么类型的安卓,因为你可能已经尝试过android-19