gpt4 book ai didi

java - android库,使用android jar

转载 作者:行者123 更新时间:2023-12-03 03:32:22 39 4
gpt4 key购买 nike

我想制作一个使用SharedPreferences的库。现在要做的是,我需要有android.jar可用。但是,由于我的项目永远不会独立运行,因此我高度怀疑使其成为功能完善的android应用程序是正确的方法。

现在,我有以下build.gradle:

apply plugin: 'eclipse'
apply plugin: 'maven'

buildscript {
repositories {
jcenter()
}


dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}


apply plugin: 'android-library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.0"

repositories {
mavenCentral()
}

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
testCompile 'junit:junit:4.12'
testCompile 'org.slf4j:slf4j-simple:1.6.1'

}
}

而且还会出现以下错误:

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring root project 'NetworkSynchronizer'.

    java.io.FileNotFoundException: D:\Users\Beheerder\git\NetworkSynchronizer\src\main\AndroidManifest.xml (The system cannot find the file specified)

  • 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行,以获取更多日志输出。


  • 这是正确的方法吗?我应该只添加一个AndroidManifest.xml,还是应该如何处理?

最佳答案

将AndroidManifest添加到您的库中:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="<YOUR_PACKAGE_HERE>">

<application android:allowBackup="true"
android:label="@string/app_name">

</application>
</manifest>

因为您使用的是android-library插件,所以那绝对是正常的。最后,您将获得@aar文件,而不是jar。祝好运!

关于java - android库,使用android jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33433289/

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