zoukankan      html  css  js  c++  java
  • android开发笔记,杂

    Mapping文件地址:

    mapping文件用于在代码被混淆后,还原BUG信息。

    release模式编译项目即可产生,相对位置:工程uildoutputsmapping elease

    需要clean project能解决的:

    Error:Execution failed for task ':app:transformClassesWithJarMergingForDevDebug'.
    > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/ultrapower/mcs/engine/AudioCodecInfo.class

    debug卡在waiting for debugger

    解决方法:重启adb。

    步骤:cmd进入命令行,进入adb所在目录先后执行adb kill-server,adb start-server。

    获取APP版本号

     /**
         * 获取程序版本,参考build.gradle里面的versionName
         *
         * @param context
         * @return
         */
        public static String getVersionName(Context context) {
            PackageManager packageManager = context.getPackageManager();
    
            try {
                PackageInfo packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
                return packInfo.versionName;
            } catch (PackageManager.NameNotFoundException e) {
                return "";
            }
        }

    在桌面创建多个快捷方式

    在指定的Activity的androidmanifest.xml加入LAUNCHER的category

     <intent-filter>
                    <!--加入Launcher就可以了-->
                    <category android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>

    No Application Debuggable

    断点进不去,解决办法:

    在gradle文件的debug和release属性下,加入

    debuggable true

    举例

    去应用市场给apk打分

    Uri uri = Uri.parse("market://details?id="+getPackageName());
    
    Intent intent = new Intent(Intent.ACTION_VIEW,uri);
    
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            
    startActivity(intent);

    自动在release模式下,混淆、压缩

    打开app的build.gradle,参考下面代码进行修改

    apply plugin: 'com.android.application'
    //创建当前时间字符串 比如 0411_1213 表示 4月11号,12点13分
    def buildTime() {
        def date = new Date()
        def formattedDate = date.format('MMdd_HHmm')
        return formattedDate
    }
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        signingConfigs {
            release {
                keyAlias 'kimmy'
                keyPassword '123456'
                storeFile file('../test.jks')
                storePassword 'xl123456'
            }
        }
        defaultConfig {
            applicationId "com.zhexian.learn.myapplication"
            minSdkVersion 14
            targetSdkVersion 23
            versionCode 77
            versionName "1.0"
        }
        buildTypes {
            release {
                debuggable true
                shrinkResources true
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                signingConfig signingConfigs.release
    
                applicationVariants.all { variant ->
                    variant.outputs.each { output ->
                        if (output.outputFile != null && output.outputFile.name.endsWith('.apk')
                                && 'release'.equals(variant.buildType.name)) {
                            String flavorName = variant.flavorName;
                            String versionName = variant.versionName;
                            String parentFile = output.outputFile.getParent();
                            if (flavorName != null && !flavorName.equals("")) {
                                output.outputFile = new File(parentFile, "${variant.buildType.name}_${flavorName}_v${versionName}_${buildTime()}.apk")
                            } else {
                                output.outputFile = new File(parentFile, "release_v${versionName}_${buildTime()}.apk")
                            }
                        }
                    }
                }
            }
            debug {
                debuggable true
                jniDebuggable true
                minifyEnabled false
                shrinkResources false
                pseudoLocalesEnabled false
                signingConfig signingConfigs.release
            }
        }
    }
  • 相关阅读:
    vs编译错误error C2059 由extern "C"导致的错误处理
    原生JS:响应式轮播图
    JSP用户关注取关实现
    JSP和AJAX实现登录注册
    MySQL常用命令
    offsetWidth/getBoundingRect()/scrollWidth/client用法总结
    画廊相册—原生JavaScript实现
    《JavaScript DOM 编程艺术》读书笔记
    天猫网页前端实现
    Docker安装和配置(链接集合)
  • 原文地址:https://www.cnblogs.com/kimmy/p/4816113.html
Copyright © 2011-2022 走看看