ラベル Android Studio の投稿を表示しています。 すべての投稿を表示
ラベル Android Studio の投稿を表示しています。 すべての投稿を表示

2015年3月29日日曜日

[AndroidSDK]Error:Execution failed for task ':app:dexDebug'.

Android StudioでEclipseで作られたAndroidプロジェクトをインポートしたところ以下のエラーが発生した。

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: 
Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java''
finished with non-zero exit value 2

このログにある
Execution failed for task ':app:dexDebug'.
というエラーの原因は複数ある

EclipseからAndroid Studioのせかえ時のgradle対応でハマったエラーまとめ
http://qiita.com/konifar/items/dbbbfd94ad103239c627

Android Studio: Gradle - build fails — Execution failed for task ':dexDebug'
http://stackoverflow.com/questions/18021901/android-studio-gradle-build-fails-execution-failed-for-task-dexdebug

今回こちらで発生したエラーは
試験用と本番用2つの*.jarのライブラリに同名のクラスがあったため発生した。
重複クラスがあるライブラリのうち1つをgradleファイルから外して解決した

このエラーが発生した時はライブラリを見なおしてみると良い


dependencies {
//    compile files('libs/samplelib_testing.jar')
compile files('libs/samplelib.jar')
}

2015年3月17日火曜日

[AndroidSDK]用意した配列を読み込む

res -> values に arrays.xmlを作成し 配列を作成する

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="sample">
        <item>value1</item>
        <item>value2</item>
        <item>value3</item>
    </string-array>
</resources>

呼び出すときは

String[] stringArray = (String[]) getResources().getStringArray(R.array.sample);

2015年3月8日日曜日

[AndroidSDK]Android Studioでコード補完が無効になった

Android Studio1.1でコード補完(macではControl+Space)が反応しなくなったことがある。

2つ以上のプロジェクトを開くとコード補完がおかしくなる、っぽい
コーディングするときは1つのプロジェクトにしよう。

バージョンアップで修正されることを祈ろう

2015年2月26日木曜日

[AndroidSDK]Dependency Project:application:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency.

AndroidStudioで以下のエラーが発生した
Warning:
Dependency Project:application:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. 
File:Users/UserName/AndroidStudioProjects/project/application/build/outputs/apk/application-release-unsigned.apk

プロジェクトの依存関係がおかしい、らしく原因は
apply plugin: 'com.android.application'
build.graleで保持しているアプリケーションが2つあったので
1つを
apply plugin: 'com.android.library'
にしてインポートしたところ解消された。

ライブラリにしたモジュールはbuild.graleからapplicationIdを削除する必要がある。

Android Studioでは
プロジェクト -> アプリケーション
                   -> ライブラリ
                   -> モジュール
といった関係でプロジェクト内には3種類のリソースがあるようだ

2015年2月25日水曜日

[AndroidSDK]Android Studio for macでオートインポートが動作しない

macでAuto importは
Control + Option + o
となっているが動作がうまくいっていなかったが
設定が足りなかった。

Android Studio -> Preferences -> Editor ->Auto Import > Insert imports on paste
-> All
に設定、さらに
Add unambigious imports on the fly
にチェックをする必要がある。

stackoverflow
What is the shortcut to Auto import all in Android Studio?
http://stackoverflow.com/questions/16615038/what-is-the-shortcut-to-auto-import-all-in-android-studio

2015年2月18日水曜日

[AndroidSDK]Gradle DSL method not found: 'compile()'

Android Studioで追加されたBuild.gradleでGithubにあるモジュールをしようと
dependenciesを追加したところ以下のエラーが発生した。
Gradle DSL method not found: 'compile()'

結果からと言うとprojectのbuild.gradleではなくappのbuild.gradleにdependenciesを追加すると良い

stackoverflow
Android gradle build Error:(9, 0) Gradle DSL method not found: 'compile()'.
http://stackoverflow.com/questions/26851230/android-gradle-build-error9-0-gradle-dsl-method-not-found-compile