在为新版本创建apk时获得旧代码[英] Getting the old code when creating apk for new version

本文是小编为大家收集整理的关于在为新版本创建apk时获得旧代码的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我在上传到商店之前,我试图在上传之前测试我的应用程序,并且当我通过

创建APK时
./gradlew assembleRelease

我在日志中看到了我添加的新依赖关系,但是当我尝试测试它时:

react-native run-android --variant=release

我看到旧代码...... 当使用调试模式测试时没有问题,我看到了我的新代码

到目前为止我一直在努力:

  1. ./Gradlew Clean
  2. 删除我的构建文件夹并再次构建+重新启动我的计算机
  3. 删除我的android文件夹并再次构建

    我在每次尝试后从手机中删除了应用程序

    我正在使用以前版本

    的旧密钥库

    我不是使用VSC的Visual Studio IM(我的代码是反应本机)

    这是我的app/build.gradle文件:

     apply plugin: "com.android.application"
    
    buildscript {
    repositories {
    maven { url 'https://maven.fabric.io/public' }
       }
     dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
         }
      }
     apply plugin: 'io.fabric'
      repositories {
      maven { url 'https://maven.fabric.io/public' }
       }
      import com.android.build.OutputFile
    
    
       project.ext.react = [
       entryFile: "index.js"
        ]
    
       apply from: "../../node_modules/react-native/react.gradle"
       def enableSeparateBuildPerCPUArchitecture = false
       def enableProguardInReleaseBuilds = false
    
       android {
       compileSdkVersion 28
       buildToolsVersion "28.0.2"
       dexOptions {
         javaMaxHeapSize "4g"
      }
      defaultConfig {
      applicationId "com.vitalacy.dashboard"
      minSdkVersion 16
     targetSdkVersion 20
     versionCode 1
    versionName "1.0"
    multiDexEnabled true
    ndk {
        abiFilters "armeabi-v7a", "x86"
       }
    }
    signingConfigs {
       release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
                }
               }
              }
      splits {
          abi {
         reset()
         enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
         }
        }
     buildTypes {
        release {
          minifyEnabled enableProguardInReleaseBuilds
          proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
        }
      }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
     variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
         }
       }
      }
     }
    
     dependencies {
      compile project(':react-native-fabric')
      compile project(':react-native-vector-icons')
      compile project(':react-native-spinkit')
       compile project(':react-native-push-notification')
      compile project(':react-native-picker')
      compile project(':react-native-linear-gradient')
      compile project(':react-native-image-crop-picker')
      compile project(':react-native-firebase')
      compile project(':react-native-fcm')
      compile project(':react-native-device-info')
      compile project(':react-native-config')
      implementation project(':react-native-picker')
      implementation project(':react-native-device-info')
      implementation project(':react-native-fcm')
      implementation project(':react-native-firebase')
      implementation project(':react-native-svg')
      implementation project(':react-native-vector-icons')
      implementation project(':react-native-spinkit')
      implementation project(':react-native-push-notification')
      implementation project(':react-native-linear-gradient')
      implementation project(':react-native-image-crop-picker')
      implementation project(':react-native-config')
      implementation fileTree(dir: "libs", include: ["*.jar"])
      implementation "com.google.android.gms:play-services-gcm:15.0.1"
      implementation "com.android.support:appcompat-v7:28.0.0-rc02"
      implementation "com.facebook.react:react-native:+"  // From node_modules
      implementation 'com.google.firebase:firebase-core:16.0.1'
      implementation 'com.google.firebase:firebase-messaging:17.0.0' //17.3.1
      implementation 'com.android.support:multidex:1.0.3'
       compile('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
        transitive = true;
          }
    
        }
    
    task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
      }
     apply plugin: 'com.google.gms.google-services'
     com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
    

,这是我的android/build.gradle:

      buildscript {
     repositories {
       google()
       jcenter()
     }
   dependencies {
    classpath 'com.android.tools.build:gradle:3.2.0-alpha11'
    classpath 'com.google.gms:google-services:4.1.0'
        }
       }


     allprojects {
      repositories {
            maven { url "https://jitpack.io" }
          mavenLocal()
          google()
          jcenter()

        maven {
        url "$rootDir/../node_modules/react-native/android"
                 }

           }
        }

  ext {
   compileSdkVersion = 28
   targetSdkVersion = 28
   buildToolsVersion = "28.0.2"
   supportLibVersion = "28.0.0-rc02"
   googlePlayServicesVersion = "15.0.1"
   oreoEXPERIMENTAL = "yes"
         }

  subprojects {
    afterEvaluate {project ->
      if (project.hasProperty("android")) {
        android {
            compileSdkVersion 28
            buildToolsVersion '28.0.2'
           }
         }
      }
   }

推荐答案

使用

构建您的APK
./gradlew assemble

而不是

./gradlew assembleRelease

本文地址:https://www.itbaoku.cn/post/1937990.html

问题描述

im trying to test my app before uploading to the store and when I create the apk by

./gradlew assembleRelease

I see in the logs the new dependencies that I added but when im trying to test it:

react-native run-android --variant=release

I see the old code... when im testing with the debug mode there is no problem and I see my new code

What I have been trying so far:

  1. ./gradlew clean
  2. delete my build folder and build again+restart my computer
  3. delete my android folder and build again

    I deleted the app from my phone after every try

    I'm using the old keystore from the previous version

    I'm not using visual studio im using vsc (my code is react native)

    this is my app/build.gradle file:

     apply plugin: "com.android.application"
    
    buildscript {
    repositories {
    maven { url 'https://maven.fabric.io/public' }
       }
     dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
         }
      }
     apply plugin: 'io.fabric'
      repositories {
      maven { url 'https://maven.fabric.io/public' }
       }
      import com.android.build.OutputFile
    
    
       project.ext.react = [
       entryFile: "index.js"
        ]
    
       apply from: "../../node_modules/react-native/react.gradle"
       def enableSeparateBuildPerCPUArchitecture = false
       def enableProguardInReleaseBuilds = false
    
       android {
       compileSdkVersion 28
       buildToolsVersion "28.0.2"
       dexOptions {
         javaMaxHeapSize "4g"
      }
      defaultConfig {
      applicationId "com.vitalacy.dashboard"
      minSdkVersion 16
     targetSdkVersion 20
     versionCode 1
    versionName "1.0"
    multiDexEnabled true
    ndk {
        abiFilters "armeabi-v7a", "x86"
       }
    }
    signingConfigs {
       release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
                }
               }
              }
      splits {
          abi {
         reset()
         enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
         }
        }
     buildTypes {
        release {
          minifyEnabled enableProguardInReleaseBuilds
          proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
        }
      }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
     variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
         }
       }
      }
     }
    
     dependencies {
      compile project(':react-native-fabric')
      compile project(':react-native-vector-icons')
      compile project(':react-native-spinkit')
       compile project(':react-native-push-notification')
      compile project(':react-native-picker')
      compile project(':react-native-linear-gradient')
      compile project(':react-native-image-crop-picker')
      compile project(':react-native-firebase')
      compile project(':react-native-fcm')
      compile project(':react-native-device-info')
      compile project(':react-native-config')
      implementation project(':react-native-picker')
      implementation project(':react-native-device-info')
      implementation project(':react-native-fcm')
      implementation project(':react-native-firebase')
      implementation project(':react-native-svg')
      implementation project(':react-native-vector-icons')
      implementation project(':react-native-spinkit')
      implementation project(':react-native-push-notification')
      implementation project(':react-native-linear-gradient')
      implementation project(':react-native-image-crop-picker')
      implementation project(':react-native-config')
      implementation fileTree(dir: "libs", include: ["*.jar"])
      implementation "com.google.android.gms:play-services-gcm:15.0.1"
      implementation "com.android.support:appcompat-v7:28.0.0-rc02"
      implementation "com.facebook.react:react-native:+"  // From node_modules
      implementation 'com.google.firebase:firebase-core:16.0.1'
      implementation 'com.google.firebase:firebase-messaging:17.0.0' //17.3.1
      implementation 'com.android.support:multidex:1.0.3'
       compile('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
        transitive = true;
          }
    
        }
    
    task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
      }
     apply plugin: 'com.google.gms.google-services'
     com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
    

and this is my android/build.gradle:

      buildscript {
     repositories {
       google()
       jcenter()
     }
   dependencies {
    classpath 'com.android.tools.build:gradle:3.2.0-alpha11'
    classpath 'com.google.gms:google-services:4.1.0'
        }
       }


     allprojects {
      repositories {
            maven { url "https://jitpack.io" }
          mavenLocal()
          google()
          jcenter()

        maven {
        url "$rootDir/../node_modules/react-native/android"
                 }

           }
        }

  ext {
   compileSdkVersion = 28
   targetSdkVersion = 28
   buildToolsVersion = "28.0.2"
   supportLibVersion = "28.0.0-rc02"
   googlePlayServicesVersion = "15.0.1"
   oreoEXPERIMENTAL = "yes"
         }

  subprojects {
    afterEvaluate {project ->
      if (project.hasProperty("android")) {
        android {
            compileSdkVersion 28
            buildToolsVersion '28.0.2'
           }
         }
      }
   }

推荐答案

Build your apk with

./gradlew assemble

instead of

./gradlew assembleRelease