3

Visual Studio 2013 で vs android プラグインを使用しようとすると、多くの問題が発生します。しかし今、私は立ち往生しています。JDK と Android SDK を数回再インストールした後、次の出力が得られるようになりました。

1>ANTBUILD : [dx] error : No suitable Java found. In order to properly use the Android Developer

エラーの上に次の行があるため、これはかなり奇妙です。

1>  Envvar: JAVA_HOME is set to 'c:/Program Files (x86)/Java/jdk1.8.0_66'

したがって、実際にJDKを見つけることができるようです。しかし、何らかの理由で、後でそれを使用したくありません。

もう 1 つの奇妙な点は、出力に次の部分があることです。

1>  [gettarget] Project Target:   Android 2.2
1>  [gettarget] API level:        8

プロジェクト設定の私の設定は次のとおりですが、Android 5.0 (android-21)

vs-android pageからダウンロードした例を作成しようとしています。問題はそこにあるすべての例で同じです。

出力全体は次のとおりです。

1>------ Build started: Project: san-angeles, Configuration: Debug Android ------
1>Build started 27.10.2015 12:56:21.
1>InitializeBuildStatus:
1>  Touching "Android\Debug\san-angeles.tlog\unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>Link:
1>  All outputs are up-to-date.
1>AntBuild:
1>  Envvar: JAVA_HOME is set to 'c:/Program Files (x86)/Java/jdk1.8.0_66'
1>  Envvar: JAVA_OPTS is set to ''
1>  e:\Libs\apache-ant-1.9.6\\bin\ant.bat  debug
1>  Buildfile: D:\Dokumenty\Projects\Vyuka\VS_Android\vs-android_samples\san-angeles\AndroidApk\build.xml
1>  
1>  -set-mode-check:
1>  
1>  -set-debug-files:
1>  
1>  -check-env:
1>   [checkenv] Android SDK Tools Revision 24.4.1
1>   [checkenv] Installed at E:\Libs\android-sdk
1>  
1>  -setup:
1>       [echo] Project Name: DemoActivity
1>    [gettype] Project Type: Application
1>  
1>  -set-debug-mode:
1>  
1>  -debug-obfuscation-check:
1>  
1>  -pre-build:
1>  
1>  -build-setup:
1>  [getbuildtools] Using latest Build Tools: 23.0.1
1>       [echo] Resolving Build Target for DemoActivity...
1>  [gettarget] Project Target:   Android 2.2
1>  [gettarget] API level:        8
1>       [echo] ----------
1>       [echo] Creating output directories if needed...
1>      [mkdir] Created dir: D:\Dokumenty\Projects\Vyuka\VS_Android\vs-android_samples\san-angeles\AndroidApk\bin\rsObj
1>      [mkdir] Created dir: D:\Dokumenty\Projects\Vyuka\VS_Android\vs-android_samples\san-angeles\AndroidApk\bin\rsLibs
1>       [echo] ----------
1>       [echo] Resolving Dependencies for DemoActivity...
1>  [dependency] Library dependencies:
1>  [dependency] No Libraries
1>  [dependency] 
1>  [dependency] ------------------
1>  [dependency] API<=15: Adding annotations.jar to the classpath.
1>       [echo] ----------
1>       [echo] Building Libraries with 'debug'...
1>     [subant] No sub-builds to iterate on
1>  
1>  -code-gen:
1>  [mergemanifest] Found Deleted Target File
1>  [mergemanifest] Merging AndroidManifest files into one.
1>  [mergemanifest] Manifest merger disabled. Using project manifest only.
1>       [echo] Handling aidl files...
1>       [aidl] No AIDL files to compile.
1>       [echo] ----------
1>       [echo] Handling RenderScript files...
1>       [echo] ----------
1>       [echo] Handling Resources...
1>       [aapt] Found Deleted Target File
1>       [aapt] Generating resource IDs...
1>       [echo] ----------
1>       [echo] Handling BuildConfig class...
1>  [buildconfig] Generating BuildConfig class.
1>  
1>  -pre-compile:
1>  
1>  -compile:
1>      [javac] Compiling 2 source files to D:\Dokumenty\Projects\Vyuka\VS_Android\vs-android_samples\san-angeles\AndroidApk\bin\classes
1>ANTBUILD : [javac] warning : [options] source value 1.5 is obsolete and will be removed in a future release
1>ANTBUILD : [javac] warning : [options] target value 1.5 is obsolete and will be removed in a future release
1>ANTBUILD : [javac] warning : [options] To suppress warnings about obsolete options, use -Xlint:-options.
1>      [javac] 3 warnings
1>  
1>  -post-compile:
1>  
1>  -obfuscate:
1>  
1>  -dex:
1>        [dex] input: D:\Dokumenty\Projects\Vyuka\VS_Android\vs-android_samples\san-angeles\AndroidApk\bin\classes
1>        [dex] input: E:\Libs\android-sdk\tools\support\annotations.jar
1>        [dex] Pre-Dexing E:\Libs\android-sdk\tools\support\annotations.jar -> annotations-ae0d3fb44877d22b7173c3abe3590afa.jar
1>         [dx] 
1>ANTBUILD : [dx] error : No suitable Java found. In order to properly use the Android Developer
1>         [dx] Tools, you need a suitable version of Java JDK installed on your system.
1>         [dx] We recommend that you install the JDK version of JavaSE, available here:
1>         [dx]   http://www.oracle.com/technetwork/java/javase/downloads
1>         [dx] 
1>         [dx] If you already have Java installed, you can define the JAVA_HOME environment
1>         [dx] variable in Control Panel / System / Avanced System Settings to point to the
1>         [dx] JDK folder.
1>         [dx] 
1>         [dx] You can find the complete Android SDK requirements here:
1>         [dx]   http://developer.android.com/sdk/requirements.html
1>         [dx] 
1>         [dx] The system cannot execute the specified program.
1>        [dex] Found Deleted Target File
1>        [dex] Converting compiled files and external libraries into D:\Dokumenty\Projects\Vyuka\VS_Android\vs-android_samples\san-angeles\AndroidApk\bin\classes.dex...
1>         [dx] 
1>ANTBUILD : [dx] error : No suitable Java found. In order to properly use the Android Developer
1>         [dx] Tools, you need a suitable version of Java JDK installed on your system.
1>         [dx] We recommend that you install the JDK version of JavaSE, available here:
1>         [dx]   http://www.oracle.com/technetwork/java/javase/downloads
1>         [dx] 
1>         [dx] If you already have Java installed, you can define the JAVA_HOME environment
1>         [dx] variable in Control Panel / System / Avanced System Settings to point to the
1>         [dx] JDK folder.
1>         [dx] 
1>         [dx] You can find the complete Android SDK requirements here:
1>         [dx]   http://developer.android.com/sdk/requirements.html
1>         [dx] 
1>         [dx] The system cannot execute the specified program.
1>  
1>  -crunch:
1>     [crunch] Crunching PNG Files in source dir: D:\Dokumenty\Projects\Vyuka\VS_Android\vs-android_samples\san-angeles\AndroidApk\res
1>     [crunch] To destination dir: D:\Dokumenty\Projects\Vyuka\VS_Android\vs-android_samples\san-angeles\AndroidApk\bin\res
1>     [crunch] Crunched 0 PNG files to update cache
1>  
1>  -package-resources:
1>       [aapt] Creating full resource package...
1>  
1>  -package:
1>  [apkbuilder] Current build type is different than previous build: forced apkbuilder run.
1>  [apkbuilder] Creating DemoActivity-debug-unaligned.apk and signing it with a debug key...
1>  
1>  BUILD FAILED
4

3 に答える 3

6

あなたは64ビットOSにいると思います。

問題の根本原因は、Android ツールチェーンが Java 実行可能ファイルへのフル パスを取得するために使用するバッチ ファイルにあります。これは、android_sdk\tools\lib\find_java.batにあります。

不可解なことに、バッチ ファイルは、64 ビット Windowsの「 Program Files (x86) 」フォルダではなく、「 Program Files」フォルダの下でのみ Java 実行可能ファイルを検索します。

JDK の 64 ビット バージョンをインストールした場合は問題ありませんが、代わりに 32 ビット バージョンをインストールした場合は失敗します。覚えている限り、vs-androidを正常に動作させるには 32 ビット バージョンが必要です。それ以外の場合は、Java を呼び出すときに失敗します。 msbuild タスクの問題 (トラッカーに関連していると思われるもの) のため、Visual Studio 内から。

私が見つけた最も簡単な解決策は、システム環境変数 (既にあると思います) で JAVA_HOME を定義し、find_java.batファイル内の次のコード (44 行目から) を変更することです。

41:    rem Check we have a valid Java.exe in the path. The return code will
42:    rem be 0 if the command worked or 1 if the exec failed (program not found).
43:    for /f "delims=" %%a in ('"%~dps0\find_java%arch_ext%.exe" -s') do set java_exe=%%a
44:    if not defined java_exe goto :CheckFailed

他の人のために:

44: if defined java_exe goto :SearchJavaW
45: 
46: rem Try to find java.exe by using JAVA_HOME if the previous step failed
47: if "%JAVA_HOME%" == "" goto :CheckFailed
48: set java_exe=%JAVA_HOME%\bin\java.exe
49: if not defined java_exe goto :CheckFailed
50: if not exist "%java_exe%" goto :CheckFailed
51: 

マニフェスト ファイルの uses-sdk 設定に関連し、プロジェクトの vs-android 設定とは関係のない API レベルに関するメッセージについて。詳細については、このリンクを参照してください: http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

vs-android の 1 つは、ビルド時に適切なヘッダーとライブラリを選択するためにビルド時に使用され、もう 1 つは .apk の展開時に Android OS を示すものです。

参考になれば幸いです!:)

于 2015-11-17T15:52:47.697 に答える