質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

解決済

1回答

2612閲覧

OneDrive APIの組込後、ビルドするとエラーが出て困っています

rafiene3249

総合スコア53

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2017/07/18 01:37

###前提・実現したいこと
OneDrive APIの組込をして、ビルドでエラーが出ないようにしたいのです。
OneDrive APIの組込自体はFile>New>Import Moduleして組み込んであります。
また、[com.onedrive.sdk]を参照出来るようにはしてあります。(自作したプロジェクトにOneDriveSDK APIを紐付けてあります)

###発生している問題・エラーメッセージ

OneDrive APIの組込後、ビルドするとAndroidManifestのマージでエラーが出てビルドに失敗するので困っています。 【Gradle Consoleに表示されているエラー内容】 C:\AndroidStudioProjects\StaffCalendar\app\src\main\AndroidManifest.xml:27:9-31 Error: Attribute meta-data#android.support.VERSION@value value=(25.3.1) from [com.android.support:appcompat-v7:25.3.1] AndroidManifest.xml:27:9-31 is also present at [com.android.support:support-v4:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1). Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:34 to override.

###該当のソースコード

Android

1【元々のAndroidManifest.xml】(一部抜粋&まずい所は伏せてあります) 2 3418 <activity 519 android:name=".MainActivity" 620 android:screenOrientation="portrait" 721 > 822 <intent-filter> 923 <action android:name="android.intent.action.MAIN" /> 1024 <action android:name="xxx.xxxxxxxxxxxxxxxxx.staffcalendar" /> 1125 1226 <category android:name="android.intent.category.LAUNCHER" /> 1327 1428 <action android:name="android.intent.action.VIEW" /> 1529 <category android:name="android.intent.category.DEFAULT" /> 1630 <category android:name="android.intent.category.BROWSABLE" /> 1731 1832 <!--Add in your scheme/host from registered redirect URI--> 1933 <!--By default, the scheme should be similar to 'msal[appId]' --> 2034 <data android:scheme="xxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 2135 android:host="auth" /> 2236 </intent-filter> 2337 </activity> 24

###試したこと
【自分なりの訳】
属性 meta-dataの「android.support.VERSION@value」が「25.3.1」でAndroidManifest.xmlの27行で定義されていて
[com.android.support:support-v4:26.0.0-alpha1]のAndroidManifest.xmlの27行では、
「android.support.VERSION@value」が「26.0.0-alppha1」になっている
提案:オーバーライドする為にAndroidManifest.xmlの25行の<meta-data>の要素に「tools:replace="android:value"」を追記しろ

上記の様に解釈したので、以下の様に修正し、リビルドしてみたのですが

【修正後のAndroidManifest.xml】(一部抜粋)


22 <intent-filter>
23 <action android:name="android.intent.action.MAIN" />
24 <action android:name="xxx.xxxxxxxxxxxxxxxxx.staffcalendar" />
25 <!--追記 ここから-->
26 <meta-data tools:replace="android:value" />
27 <!--ここまで-->
28
(~~~(省略)~~~)
39 </intent-filter>

下記のエラーが出ました。

【Gradle Consoleに表示されているエラー内容】

C:\AndroidStudioProjects\StaffCalendar\app\src\main\AndroidManifest.xml:26:17-60 Error:
Missing 'name' key attribute on element meta-data at AndroidManifest.xml:26:17-60
C:\AndroidStudioProjects\StaffCalendar\app\src\main\AndroidManifest.xml:26:17-60 Error:
tools:replace specified at line:26 for attribute android:value, but no new value specified

【自分なりの訳】
AndroidManifest.xmlの26行の要素 meta-dataのキー 'name' が無い
AndroidManifest.xmlの26行に属性「android:value」の為の「tools:replace 」が定義されているが、
新しい値が定義されていない

ええと、つまりこう直せばいいのか?と、以下の様に修正してリビルドしました。

【修正後のAndroidManifest.xml】(一部抜粋)


25 <!--追記後の修正 ここから-->
26 <meta-data tools:replace="android:value"
27 android:name="android.support.VERSION"
28 android:value="25.3.1" />
29 <!--ここまで-->

すると下記のエラーが出ました。

【Gradle Consoleに表示されているエラー内容】

C:\AndroidStudioProjects\StaffCalendar\app\src\main\AndroidManifest.xml:28:21-43 Error:
Attribute meta-data#android.support.VERSION@value value=(25.3.1) from AndroidManifest.xml:28:21-43
is also present at [com.android.support:support-v4:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1).
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:34 to override.

【自分なりの訳】
AndroidManifest.xmlの28行で属性 meta-dataのandroid.support.VERSIONの値が(25.3.1)だが、
[com.android.support:support-v4:26.0.0-alpha1]のAndroidManifest.xmlの27行では(26.0.0-alpha1)となっている
提案:オーバーライドする為にAndroidManifest.xmlの25行の<meta-data>の要素に「tools:replace="android:value"」を追記しろ

えーと・・・? じゃぁこれでどう?と、以下の様に変更してリビルド

<!--追記後の修正 ここから--> <meta-data tools:replace="android:value" android:name="android.support.VERSION" android:value="26.0.0-alpha1" /> <!--ここまで-->

【Gradle Consoleに表示されているエラー内容】

C:\AndroidStudioProjects\StaffCalendar\app\src\main\AndroidManifest.xml:28:21-50 Error:
Attribute meta-data#android.support.VERSION@value value=(25.3.1) from AndroidManifest.xml:28:21-50
is also present at [com.android.support:support-v4:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1).
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:34 to override.

あれ? valueの値変えてみたのにエラーの内容に変化がない。 だめだ、よく分からない、お手上げだ。
と言った次第です。
###補足情報(言語/FW/ツール等のバージョンなど)
Android Studio 2.3.3 (Java)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

###自己解決しました(長文失礼)
module appの所のbuild.gradleを開いて
dependenciesの compile 'com.android.support:appcompat-v7:25.3.1' に赤線が
カーソル合わせると赤い風船が出る

メッセージ出てたのでちょっと長いけど転記:

All com.android.support libraries must use the exact same version specification(mixing version can lead to runtime crashes.)Found versions 26.0.0-alpha,25.3.1.Examples include
com.android.support:support-compat:26.0.0-alpha and com.android.support:animated-vector-drawble:25.3.1 les...(Ctrl+F1)

There are some combination of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support
libraries that is not the latest version(or in particular, a version lower than your targetSDKVersion.)

試しに There are ~ your targetSDKVersion.) でググってみたら以下のHPを発見

Android アプリ開発時のライブラリバージョン競合対策

これは・・当たりか!?ということで、上記HPの内容を元にTerminalから下記コマンドを実行

gradlew -q dependencies app:dependencies --configuration compile

実行結果

compile - Classpath for compiling the main sources.
+--- com.android.support:appcompat-v7:25.3.1
| +--- com.android.support:support-annotations:25.3.1 -> 26.0.0-alpha1
| +--- com.android.support:support-v4:25.3.1 -> 26.0.0-alpha1
| | +--- com.android.support:support-compat:26.0.0-alpha1
| | | --- com.android.support:support-annotations:26.0.0-alpha1
| | +--- com.android.support:support-media-compat:26.0.0-alpha1
| | | +--- com.android.support:support-annotations:26.0.0-alpha1
| | | --- com.android.support:support-compat:26.0.0-alpha1 ()
| | +--- com.android.support:support-core-utils:26.0.0-alpha1
| | | +--- com.android.support:support-annotations:26.0.0-alpha1
| | | --- com.android.support:support-compat:26.0.0-alpha1 (
)
| | +--- com.android.support:support-core-ui:26.0.0-alpha1
| | | +--- com.android.support:support-annotations:26.0.0-alpha1
| | | --- com.android.support:support-compat:26.0.0-alpha1 ()
| | --- com.android.support:support-fragment:26.0.0-alpha1
| | +--- com.android.support:support-compat:26.0.0-alpha1 (
)
| | +--- com.android.support:support-core-ui:26.0.0-alpha1 ()
| | --- com.android.support:support-core-utils:26.0.0-alpha1 (
)
| +--- com.android.support:support-vector-drawable:25.3.1
| | +--- com.android.support:support-annotations:25.3.1 -> 26.0.0-alpha1
| | --- com.android.support:support-compat:25.3.1 -> 26.0.0-alpha1 ()
| --- com.android.support:animated-vector-drawable:25.3.1
| --- com.android.support:support-vector-drawable:25.3.1 (
)
+--- com.android.support.constraint:constraint-layout:1.0.2
| --- com.android.support.constraint:constraint-layout-solver:1.0.2
--- project :onedrivesdk
+--- com.microsoft.services.msa:msa-auth:0.8.4
+--- com.microsoft.aad:adal:1.1.7
| +--- com.android.support:support-v4:[18,) -> 26.0.0-alpha1 (*)
| --- com.google.code.gson:gson:2.3.1
--- com.google.code.gson:gson:2.3.1

対象となるのが3つだったのでappのbuild.gradleを下記の様に書き換えた

【書換前のbuild.gradle】

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) // ↓ ここを compile 'com.android.support:appcompat-v7:25.3.1' // ↑ compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' compile project(':onedrivesdk') }

【書換後のbuild.gradle】

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) // ↓ この様に書き換えた compile 'com.android.support:appcompat-v7:26.0.0-alpha1' compile 'com.android.support:support-vector-drawable:26.0.0-alpha1' compile 'com.android.support:animated-vector-drawable:26.0.0-alpha1' // ↑ compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' compile project(':onedrivesdk') }

リビルド実行・・・通った!! ということで自己解決しました。

投稿2017/07/19 05:02

rafiene3249

総合スコア53

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問