前提・実現したいこと
Android Studio3.5.3にOpenCVを導入しよと試みています。
発生している問題・エラーメッセージ
下記のリンクを参考にOpenCVをImport,moduleの依存関係の追加,gladleの書き換えを行った。
しかし次のようなエラーがでる。
ERROR: The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.
###該当するコード
minSdkのバージョンをandroid manifest内で宣言しちゃだめとあったのでAndoroidManifest.xmlを確認したが思い当たる記述がなかった。
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myapplication"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
###build.gradle(Module:app)
apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion "29.0.2" defaultConfig { applicationId "com.example.myapplication" minSdkVersion 29 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' }
###build.gradle(Module:opencv)
apply plugin: 'com.android.library' println "OpenCV: " + project.buildscript.sourceFile android { compileSdkVersion 29 //buildToolsVersion "27.0.3" // not needed since com.android.tools.build:gradle:3.0.0 defaultConfig { minSdkVersion 29 targetSdkVersion 29 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_6 targetCompatibility JavaVersion.VERSION_1_6 } sourceSets { main { jniLibs.srcDirs = ['native/libs'] java.srcDirs = ['java/src'] aidl.srcDirs = ['java/src'] res.srcDirs = ['java/res'] manifest.srcFile 'java/AndroidManifest.xml' } } } dependencies { }
補足情報(FW/ツールのバージョンなど)
Android Studioのバージョン:Android Studio3.5.3
Android SDK Toolsのバージョン:26.1.1
参考にされたページの手順通りにやって成功しました。 (OpenCV Version 4.2.0 と表示された。)
OpenCV はどこから、バージョンいくつをダウンロードされましたか?
手元のファイルと比べてみましたが、
・build.gradle(Module:app) 参考ページの手順(moduleの依存関係の追加)の結果、implementation project(path: ':opencv') という行が追加されるはずです。
・build.gradle(Module:opencv) externalNativeBuild などの内容が足りない気がします。(OpenCV のバージョン違いのせいかもしれませんが。)
あなたの回答
tips
プレビュー