gpt4 book ai didi

android - 在 Android Studio 中将现有项目从 Eclipse 转换为 Gradle

转载 作者:行者123 更新时间:2023-11-29 00:17:00 26 4
gpt4 key购买 nike

我找到了一个我想从事的开源项目,但我在设置初始配置时遇到了问题。该项目似乎是用 Eclipse 编写的,我正试图让它与 Android Studio 一起工作。在经历了一些错误之后,我终于在运行之前在配置菜单中看到以下错误。

AndroidManifest.XML doesn't exist or has the incorrect root tag

我发现了很多类似 this 的答案这表明我使用 sync project with Gradle 命令,但我的项目没有使用 Gradle 设置,因为我正在构建其他人的项目。这是我第一次使用 Android Studio,所以我接下来尝试解决这个问题可能不是很好。我决定尝试通过添加我自己的 build.gradlesettings.gradle 文件使该项目成为 Gradle 项目。我的布局如下所示:

顶级:

top level

java文件夹内:

enter image description here

我尝试复制构建和设置 Gradle 文件的工作示例。我的 settings.gradle 包含以下内容:

include ':'

我的顶级 build.gradle 包含:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
//compile project(":")
}
}

allprojects {
repositories {
mavenCentral()
}
}

我的 java 级别 build.gradle 包含:

apply plugin: 'android'

android {
compileSdkVersion 20
buildToolsVersion "17.0.0"

defaultConfig {
applicationId "org.pocketworkstation.pckeyboard"
minSdkVersion 8
targetSdkVersion 19
versionCode 1037
versionName "v1.37"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
jni.srcDirs = ['jni']
}
androidTest.setRoot('tests')
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}

因为我认为这可能很重要,所以我的项目结构模块:

 project structure modules

目前尝试同步不会生成任何单词,所以我认为没问题,但这是一个很大的假设。我有什么想法要改变吗?

最佳答案

Android Studio 不会将您的项目视为基于 Gradle 的项目;您可以这样说,因为您在“项目结构”对话框中看到的许多条目不会显示基于 Gradle 的项目(即项目、库、方面和 Artifact )条目。关闭您的项目并将其重新导入为基于 Gradle 的项目,您应该没问题。

关于android - 在 Android Studio 中将现有项目从 Eclipse 转换为 Gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25833220/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com