指定使用 sbt android-plugin 编译的 Java 项目中 AndroidManifest.xml 的位置

发布于 2024-12-10 17:31:02 字数 1186 浏览 0 评论 0原文

我正在尝试使用 sbt 编译一个用 Java 编写的 Android 项目,我刚刚继承了该项目并希望使用 Scala 进行改进。

该项目分为几个模块。我使用“g8 jberkel/android-app -b sbt-0_11”创建了一个 sbt 项目,将所有模块复制到 src/ ,留下:

my-android-project  ls -l src 
total 96
drwxr-xr-x  14 tiagoboldt  staff    476 Oct 18 16:09 AndroidApplication
drwxr-xr-x   8 tiagoboldt  staff    272 Oct 18 16:09 CRCCalculatioNTool
drwxr-xr-x  10 tiagoboldt  staff    340 Oct 18 16:09 CaretakerIntegration
drwxr-xr-x  13 tiagoboldt  staff    442 Oct 18 16:09 ConsoleSensorNetwork
... and so on

这些模块之间具有依赖关系,AndroidApplication 是我想构建的主要应用程序。我一直在尝试编辑我的project/build.scala,我已将其从原始版本更改为包含以下内容:

object AndroidBuild extends Build {
  lazy val AndroidApplication = Project (
    "AndroidApplication",
    file("."),
    settings = General.fullAndroidSettings ++ PlainJavaProject.settings
  ) 
}

在尝试构建时,我总是以:

java.io.FileNotFoundException: (rest_of_dir)/my-android-project/src/main/AndroidManifest.xml (No such file or directory)

我无法理解如何配置它来拥有它在 src/AndroidApplication/src/AndroidManifest.xml 中查找该文件,而不是默认文件。已经尝试使用文件值但不行:\

sbt 及其 android 插件的文档没有帮助。任何帮助将不胜感激。

I'm trying to use sbt to compile an Android Project made in Java, which I just inherited and want to improve with Scala.

The project is splited across several modules. I've created an sbt project with "g8 jberkel/android-app -b sbt-0_11", copied all the modules to src/ leaving me with:

my-android-project  ls -l src 
total 96
drwxr-xr-x  14 tiagoboldt  staff    476 Oct 18 16:09 AndroidApplication
drwxr-xr-x   8 tiagoboldt  staff    272 Oct 18 16:09 CRCCalculatioNTool
drwxr-xr-x  10 tiagoboldt  staff    340 Oct 18 16:09 CaretakerIntegration
drwxr-xr-x  13 tiagoboldt  staff    442 Oct 18 16:09 ConsoleSensorNetwork
... and so on

These modules have dependencies between them, AndroidApplication is the main application I want to build. I've been trying to edit my project/build.scala, which I've altered from the original to include the following :

object AndroidBuild extends Build {
  lazy val AndroidApplication = Project (
    "AndroidApplication",
    file("."),
    settings = General.fullAndroidSettings ++ PlainJavaProject.settings
  ) 
}

While trying to build, I always end up with:

java.io.FileNotFoundException: (rest_of_dir)/my-android-project/src/main/AndroidManifest.xml (No such file or directory)

I can't understand how to configure it to have it look for that file in src/AndroidApplication/src/AndroidManifest.xml, instead of the default one. Already tried to play with the file value and no go :\

The documentation of both sbt and it's android plugin didn't help. Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

深海夜未眠 2024-12-17 17:31:02

与 libgdx 一起,我只使用了这个:

lazy val android = 
  Settings.common ++
  AndroidProject.androidSettings ++
  TypedResources.settings ++
  proguardSettings ++
  AndroidManifestGenerator.settings ++
  AndroidMarketPublish.settings ++
  Seq (
    platformName in Android := "android-7",
    keyalias in Android := "change-me",
    mainAssetsPath in Android := file("common/src/main/resources"),
    manifestPath in Android := Seq(file("android/src/main/AndroidManifest.xml"))
  )

Along with libgdx, I just used this:

lazy val android = 
  Settings.common ++
  AndroidProject.androidSettings ++
  TypedResources.settings ++
  proguardSettings ++
  AndroidManifestGenerator.settings ++
  AndroidMarketPublish.settings ++
  Seq (
    platformName in Android := "android-7",
    keyalias in Android := "change-me",
    mainAssetsPath in Android := file("common/src/main/resources"),
    manifestPath in Android := Seq(file("android/src/main/AndroidManifest.xml"))
  )
会傲 2024-12-17 17:31:02

希望这有帮助:

object AndroidBuild extends Build {
  val AndroidApplication = Project (
  "AndroidApplication",
  file("AndroidApplication"),
   settings = General.fullAndroidSettings ++ PlainJavaProject.settings
  ) dependsOn xxxxx 

  lazy val CRCCalculatioNTool = Project (
  "CRCCalculatioNTool",
  file("CRCCalculatioNTool"),
  settings = General.fullAndroidSettings ++ PlainJavaProject.settings
  ) dependsOn yyy

  lazy val CaretakerIntegration = Project (
  "CaretakerIntegration",
  file("CaretakerIntegration"),
   settings = General.fullAndroidSettings ++ PlainJavaProject.settings
  ) dependsOn zzz
}

Hopefully this helps:

object AndroidBuild extends Build {
  val AndroidApplication = Project (
  "AndroidApplication",
  file("AndroidApplication"),
   settings = General.fullAndroidSettings ++ PlainJavaProject.settings
  ) dependsOn xxxxx 

  lazy val CRCCalculatioNTool = Project (
  "CRCCalculatioNTool",
  file("CRCCalculatioNTool"),
  settings = General.fullAndroidSettings ++ PlainJavaProject.settings
  ) dependsOn yyy

  lazy val CaretakerIntegration = Project (
  "CaretakerIntegration",
  file("CaretakerIntegration"),
   settings = General.fullAndroidSettings ++ PlainJavaProject.settings
  ) dependsOn zzz
}
携余温的黄昏 2024-12-17 17:31:02

如果您尝试配置插件以更改默认路径,那么我认为您还需要配置设置 manifestTemplatePath

settings = General.fullAndroidSettings ++ inConfig(Android)(Seq(
  manifestPath <<= (baseDirectory, manifestName in Android) (_ / _),
  manifestTemplatePath <<= (manifestPath in Android) (mp => mp),
  mainAssetsPath <<= baseDirectory (_ / "assets"),
  mainResPath <<= baseDirectory (_ / "res")
))

删除 manifestTemplatePath ,您将收到错误正在看到。

in case you are trying to configure the plugin to change the default paths then i think you also need to configure the setting manifestTemplatePath:

settings = General.fullAndroidSettings ++ inConfig(Android)(Seq(
  manifestPath <<= (baseDirectory, manifestName in Android) (_ / _),
  manifestTemplatePath <<= (manifestPath in Android) (mp => mp),
  mainAssetsPath <<= baseDirectory (_ / "assets"),
  mainResPath <<= baseDirectory (_ / "res")
))

Remove manifestTemplatePath and you'll get the error you're seeing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文