原因:java.util.zip.ZipException:设置的代码长度无效

时间:2018-10-09 13:45:44

标签: java android maven android-studio artifactory

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

解决方案如下: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项目。

谢谢!

1 个答案:

答案 0 :(得分:1)

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