在Android Studio中添加OpenCV:依赖功能已配置,但未设置软件包ID。

huangapple go评论86阅读模式
英文:

Adding opencv to android studio: Dependent features configured but no package ID was set

问题

我正在尝试将OpenCV添加到我的AndroidStudio项目中。然而,在尝试构建项目时,我会遇到上面提到的错误:"已配置依赖功能,但未设置包ID。"

我使用了以下链接进行实现:https://android.jlelse.eu/a-beginners-guide-to-setting-up-opencv-android-library-on-android-studio-19794e220f3c
我无法按照第5步进行操作,因为没有可以选择的选项。那只是一个空白的屏幕。我假设AndroidStudio已经自动执行了那一步。我能够访问来自openCv的对象,比如"Mat",但在构建项目时,我遇到了上面提到的错误。

如果您需要更多信息,请告诉我。

英文:

I am trying to add OpenCV to my AndroidStudio project. However, I get the error mentioned above, when trying to build the project: "Dependent features configured but no package ID was set."

I used the following link for the implementation: https://android.jlelse.eu/a-beginners-guide-to-setting-up-opencv-android-library-on-android-studio-19794e220f3c
I was not able to follow step 5, because there was no option to choose from. It was just a blank screen. I assumed, that AndroidStudio already performed that step automatically. I was able to access Objects from openCv like "Mat", but when building the project, I got the error mentioned above.

If you need more information, please let me know.

答案1

得分: 2

以下是翻译好的部分:

这也发生在我的项目中,所以我在 build.gradle 文件和 Java 文件中进行了一些更改。
你也可以尝试这样做:
项目文件夹 -> java -> build.gradle 文件

打开这个文件,并像这样编辑文件 -

apply plugin: 'com.android.library'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"

    defaultConfig {
        //applicationId "org.opencv"
        minSdkVersion 16
        targetSdkVersion 29
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

尝试一下,也许对你有帮助。

英文:

It happens with my project also so i doing few changes inside my build.gradle file inside the java file.
you can try this also
Project Folder->java->build.gradle file

open this file and edit the file like this -
apply plugin: 'com.android.library'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"

    defaultConfig {
        //applicationId "org.opencv"
        minSdkVersion 16
        targetSdkVersion 29
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

try this maybe its helpful for you

答案2

得分: 1

你好,我也遇到了这个问题。
你提供的链接在OpenCV的4.+版本上不起作用。
我发现在build.gradle中有一个教程,在sdk文件夹内(sdk/build.gradle)
卸载你的SDK,然后尝试在sdk文件夹内遵循最新的教程。

// 这个文件是OpenCV项目的一部分。
// 它受到分布顶层目录和http://opencv.org/license.html中LICENSE文件中的许可条款的约束。

//
// 以下是将OpenCV集成到现有Android Studio应用程序项目中的注意事项(应该存在' app '模块)。
//
// 此文件位于<OpenCV-android-sdk> / sdk目录中(位于' etc ',' java ',' native '子目录附近)
//
// 将模块添加到Android Studio应用程序项目中:
//
// - Android Studio方式:
//   (将几乎所有OpenCV Android SDK复制到您的项目中,约200Mb)
//
//   导入模块:菜单->“文件”->“新建”->“模块”->“导入Gradle项目”:
//   源目录:选择此“ sdk ”目录
//   模块名称:“:opencv”
//
// - 或者从OpenCV Android SDK附加库模块
//   (不将其复制到应用程序项目目录中,允许在项目之间共享相同的模块)
//
//   编辑“settings.gradle”并添加以下行:
//
//   def opencvsdk=' <path_to_opencv_android_sdk_rootdir> '
//   //您可以将上述声明放入gradle.properties文件中(包括HOME目录中的文件),
//   //但不要使用'def'和撇号符号('):opencvsdk=<path_to_opencv_android_sdk_rootdir>
//   include ':opencv'
//   project(':opencv').projectDir = new File(opencvsdk + '/sdk')

// 将依赖项添加到应用程序模块:
//
// - Android Studio方式:
//   “打开模块设置”(F4)->“依赖项”选项卡
//
// - 或者将“project(':opencv')”依赖项添加到app/build.gradle中:
//
//   dependencies {
//       implementation fileTree(dir: 'libs',include: ['*.jar'])
//       ...
//       implementation project(':opencv')
//   }
//
// 在使用之前加载OpenCV本地库:
//
// - 避免使用“OpenCVLoader.initAsync()”方法-它已弃用
//   它可能会加载具有不同版本的库(从单独安装在设备上的OpenCV Android Manager加载)
//
// - 使用“System.loadLibrary('opencv_java4')”或“OpenCVLoader.initDebug()”
英文:

Hello I experience this problem also.
The link you provide does not work on version 4.+.+ of opencv.
I found there is a tutorial in build.gradle, inside the sdk folder(sdk/build.gradle).
Unload your sdk and try following the latest tutorial inside the sdk folder.

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.

//
// Notes about integration OpenCV into existed Android Studio application project are below (application &#39;app&#39; module should exist).
//
// This file is located in &lt;OpenCV-android-sdk&gt;/sdk directory (near &#39;etc&#39;, &#39;java&#39;, &#39;native&#39; subdirectories)
//
// Add module into Android Studio application project:
//
// - Android Studio way:
//   (will copy almost all OpenCV Android SDK into your project, ~200Mb)
//
//   Import module: Menu -&gt; &quot;File&quot; -&gt; &quot;New&quot; -&gt; &quot;Module&quot; -&gt; &quot;Import Gradle project&quot;:
//   Source directory: select this &quot;sdk&quot; directory
//   Module name: &quot;:opencv&quot;
//
// - or attach library module from OpenCV Android SDK
//   (without copying into application project directory, allow to share the same module between projects)
//
//   Edit &quot;settings.gradle&quot; and add these lines:
//
//   def opencvsdk=&#39;&lt;path_to_opencv_android_sdk_rootdir&gt;&#39;
//   // You can put declaration above into gradle.properties file instead (including file in HOME directory),
//   // but without &#39;def&#39; and apostrophe symbols (&#39;): opencvsdk=&lt;path_to_opencv_android_sdk_rootdir&gt;
//   include &#39;:opencv&#39;
//   project(&#39;:opencv&#39;).projectDir = new File(opencvsdk + &#39;/sdk&#39;)
//
//
//
// Add dependency into application module:
//
// - Android Studio way:
//   &quot;Open Module Settings&quot; (F4) -&gt; &quot;Dependencies&quot; tab
//
// - or add &quot;project(&#39;:opencv&#39;)&quot; dependency into app/build.gradle:
//
//   dependencies {
//       implementation fileTree(dir: &#39;libs&#39;, include: [&#39;*.jar&#39;])
//       ...
//       implementation project(&#39;:opencv&#39;)
//   }
//
//
//
// Load OpenCV native library before using:
//
// - avoid using of &quot;OpenCVLoader.initAsync()&quot; approach - it is deprecated
//   It may load library with different version (from OpenCV Android Manager, which is installed separatelly on device)
//
// - use &quot;System.loadLibrary(&quot;opencv_java4&quot;)&quot; or &quot;OpenCVLoader.initDebug()&quot;

huangapple
  • 本文由 发表于 2020年7月26日 00:17:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/63090645.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定