【问题标题】:Specifying the location of AndroidManifest.xml in a Java project compiled with sbt android-plugin在使用 sbt android-plugin 编译的 Java 项目中指定 AndroidManifest.xml 的位置
【发布时间】:2011-12-10 05:49:18
【问题描述】:

我正在尝试使用 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 插件的文档都没有帮助。任何帮助,将不胜感激。

【问题讨论】:

    标签: android scala build android-manifest sbt


    【解决方案1】:

    与 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"))
      )
    

    【讨论】:

      【解决方案2】:

      希望这会有所帮助:

      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
      }
      

      【讨论】:

        【解决方案3】:

        如果您尝试配置插件以更改默认路径,那么我认为您还需要配置设置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,你会看到你看到的错误。

        【讨论】:

          猜你喜欢
          • 2011-09-21
          • 2021-05-11
          • 1970-01-01
          • 1970-01-01
          • 2014-06-01
          • 2017-04-11
          • 2015-02-01
          • 2011-01-13
          • 1970-01-01
          相关资源
          最近更新 更多