Coder Social home page Coder Social logo

gradlepage's Introduction

Android Studio升级3.0,自带Gradle打包

升级到android studio 3.0之后,多渠道打包方式有点变化,对出现的错误记录。

环境如下:
Android Studio 3.0.1
JDK 1.8
Gradle 4.1
MAC OS 10.13
记录要点
1. 签名方式(SigningEnabled)
2. 渠道配置(productFlavors)

1.主要在签名方式和渠道配置和以前不一样,虽然android studio 2.2就支持V2(Full APK Signature),一直使用的是V1(Jar Signature), 开启V1,V2直接在Gradle中配置,把v1SigningEnabled,v2SigningEnabled设置为true,如图

image

2.渠道配置和友盟多渠道方式差不多,在AndroidManifest.xml中配置mata-data image 在app build.gradle如果按照友盟以前那样配置会出现以下错误

Error:All flavors must now belong to a named flavor dimension. The flavor 'xiaomi' is not assigned to a flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html

正确配置如图 image

在MainActivity中获取渠道号

image

在Terminal中输入命令生成不同渠道APK

所有渠道
./gradlew assembleRelease
只生成小米渠道
./gradlew assemblexiaomiRelease

运行APP就能看到渠道号 image

验证签名很简单,在Sdk中就有打包检查工具

使用方法:

进入 Sdk->build-tools->25.0.3

验证 apksigner verify --verbose 《apk的位置》

结果显示有一个签名者,使用了V1,V2签名

image

如果想获取更多签名信息可以查看 Android-GetAPKInfo

gradlepage's People

Contributors

zhoucarson avatar

Watchers

 avatar

Forkers

570622566

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.