将项目导入 Android Studio 后出错
Error after importing project to Android Studio
我收到了一个旧代码,编码于2014年,我被要求更新一些功能。
我在运行代码时遇到问题,因为它是在 Eclipse 上构建的,现在我将其导入到 Android Studio 中。
首先,代码调用了项目中包含的 3 个库,其中一个在 cpp 中。这就是为什么我认为需要添加捆绑 ndk。
我添加了:android.useDeprecatedNdk=true to gradle-wrapper.properties
这些是我目前拥有的 gradle 文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
}
}
allprojects {
repositories {
jcenter()
}
}
第一图书馆格拉德尔
apply plugin: 'com.android.library'
android {
compileSdkVersion 16
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 5
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
第二图书馆
apply plugin: 'com.android.library'
android {
compileSdkVersion 16
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 5
targetSdkVersion 5
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':FirstLibrary')
compile 'com.android.support:support-v4:18.0.0'
compile files('libs/libGoogleAnalyticsV2.jar')
}
第三图书馆
apply plugin: 'com.android.library'
android {
compileSdkVersion 16
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 5
targetSdkVersion 7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
项目模块分级
apply plugin: 'com.android.application'
android {
compileSdkVersion 8
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.application.id"
minSdkVersion 8
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
}
dependencies {
compile project(':secondLbrary')
compile project(':thirdLibrary')
}
收到的最新错误:
错误:任务":库:编译调试NDK"执行失败。
错误:您的项目包含C++文件,但它未使用受支持的本机生成系统。 考虑将CMake或ndk-build与稳定的Android Gradle插件集成: https://developer.android.com/studio/projects/add-native-code.html 或使用实验插件: http://tools.android.com/tech-docs/new-build-system/gradle-experimental。
我该怎么做才能对此进行调查?
这通常与 gradle 版本有关 - 您应该更新到最新版本并重试。看这里插件太旧了。
另外 - 为什么需要"com.android.tools.build:gradle-experimental:0.7.0-alpha4"?
要在 Android Studio 中编译 cpp 代码:
-
您需要在Android SDK Manager上下载CMAKE,LLDB和NDK。
-
您需要制作CMakeList.txt并且需要放置用于编译CPP文件的脚本。
-
您需要在build.gradle中放置以下行:
externalNativeBuild { cmake { path "CMakeLists.txt" } }
- 使用 Visual Studio 2019 构建 Hello World wxwidgets 应用程序时出错
- 在Visual Studio中使用vcpkg使用paho-mqtt x64时出错
- 使用 Visual Studio 代码读取 C++ 中的输入流时出错
- 将 boost 与 Visual Studio 和 vcpkg 链接时出错
- 将项目导入 Android Studio 后出错
- 将 Dr. Memory 与 Visual Studio 项目配合使用时出错:缺少应用程序所需的库
- 尝试返回指向 Visual Studio 中的动态数组的指针时出错C++
- 在 Visual Studio 2015 中生成 vsal 项目时出错
- 构建 Dlib Visual Studio 2015 时出错
- 创建新的 Visual Studio c++ 项目时出错
- Visual Studio 2017 加载规则集文件时出错
- 使用 Visual Studio 2017 时出错:fscanf_s
- 在另一台计算机上打开 Visual Studio 项目的.exe时出错
- 在Visual Studio中使用Cygwin编译的dll的库函数时出错
- 将事件处理程序添加到任何控件都会导致 Visual Studio 中出错
- 在 Visual Studio 2015 社区中消除错误时出错
- 在C++Visual Studio 2012中创建类时出错
- 使用Visual Studio构建Freetype应用程序时出错
- 在Visual Studio 2013上使用OpenCV 2.4.10时出错
- Visual Studio报告对结构向量的push_back()函数调用出错