java - 由 : java. util.zip.ZipException 引起:设置的代码长度无效

标签 java android maven android-studio artifactory

我在尝试在 Android Studio 上构建项目时收到此错误。当尝试使用 res/raw/file.dat 上的二进制文件压缩最终 Artifact 时会发生这种情况。

解决方案如下所述:Maven corrupting binary files in source/main/resources when building jar

是将文件或 res/raw 文件夹添加到构建时的“false”过滤中。但问题是我使用 JFrog Articatory 配置我的内部 Maven 存储库,如下所示:https://inthecheesefactory.com/blog/how-to-setup-private-maven-repository/en

问题: 如何转换:

 <project>
      <build>
          <resources>
              <resource>
                  <directory>${basedir}/src/main/resources/lib</directory>
                  <filtering>false</filtering>
              </resource>
          </resources>
          <plugins>
              ...
          </plugins>
      </build>
</project>   

进入gradle风格:

def libraryGroupId = 'XXXXXXX'
def libraryArtifactId = 'XXXXXX'
def libraryVersion = '0.0.1'

publishing {
    publications {
        aar(MavenPublication) {
            groupId libraryGroupId
            version libraryVersion
            artifactId libraryArtifactId

            artifact("$buildDir/outputs/aar/${artifactId}-release.aar")
        }

    }

}

artifactory {
    contextUrl = 'XXXXXXXXXX'
    publish {
        repository {
            repoKey = 'libs-release-local'

            username = artifactory_username
            password = artifactory_password
        }
        defaults {
            publications('aar')
            publishArtifacts = true


            properties = ['qa.level': 'basic', 'q.os': 'android', 'dev.team': 'core']
            publishPom = true
        }
    }

我尝试过使用 pom.xml,但它一直说无法识别 .xml 文件中的 TAG 项目。

谢谢!!!

最佳答案

android {
    sourceSets {
        main {
            assets.srcDirs = ['src/main/res/raw']
        }
    }
}

关于java - 由 : java. util.zip.ZipException 引起:设置的代码长度无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52722632/

相关文章:

java - LibGdx 使用 ArrayList 进行数据持久化

linux - Maven 复制文件和文件夹插件不复制 linux [dot] ".*"隐藏文件

java - 从 Eclipse 运行 Jboss EAP 6.3 时出错?

maven - Tycho 中如何使用同一个目标平台多个子项目

java - 读取 jackson 中的嵌入式对象

java - PaintComponent 不在 Jpanel 上绘制 Sprite

android - 解析数据时出错 org.json.JSONException : Value ���� of type java. lang.String 无法转换为 JSONObject

java - 如何使用Java的String.hashCode()函数来制作哈希表?

java - 基本GUI程序布局定位

android - 如何使用 Dagger @Inject 到 Kotlin Builder 类中