首页 > 解决方案 > gradlew assembleRelease 生成两个版本的APK(新旧一个)

问题描述

我通过生成 APK 文件gradlew assembleRelease并通过adb install app-release.apk. 问题是,当我第一次运行应用程序时一切正常,但如果我关闭应用程序(android 任务按钮 > 全部关闭)并重新运行应用程序,我会得到我的应用程序的非常旧版本(两个月前生成)。

我试过的:

cd android && ./graldew clean // before generating the APK

我也遵循以下步骤:

1.Delete (index.android.bundle) files inside directory android/app/src/main/assets.

2.run react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

3.Delete folders (drawable,drawable-hdpi,drawable-mdpi,drawable-xhdpi,drawable-xxhdpi,drawable-xxxhdpi,raw) inside android/app/src/main/res

4. ./gradlew clean > ./gradlew assembleReleae

但它不起作用。这是更多信息:

//package.json
{
  "name": "ktIP",
  //...
  },
  "rnpm": {
    "assets": [
      "./assets/fonts"
    ]
  },
  "dependencies": {

    "react": "16.8.3",
    "react-native": "0.59.1",


  },
  "devDependencies": {
    "@babel/core": "^7.3.4",
    "@babel/runtime": "^7.3.4",
    "@types/jest": "^26.0.0",
    "@types/react": "^16.9.38",
    "@types/react-native": "^0.62.13",
    //...
  },
}

//build.gradlew
buildscript {
    ext      { 
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 30 
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath 'com.google.gms:google-services:4.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

我可以编辑我的问题以获取更多信息。

如果我运行同样的问题,react-native run-android --variant=release但我在调试版本中运行良好,react-native run-android

不知道是不是因为React Native(59)老版本的原因,要不要升级到63

标签: androidreact-nativeapk

解决方案


推荐阅读