【问题标题】:Why im getting my code before change when I created new apk in android?当我在 android 中创建新的 apk 时,为什么我在更改之前获取我的代码?
【发布时间】:2018-09-26 14:46:28
【问题描述】:

我正在尝试在上传到商店之前以及通过以下方式创建 apk 时测试我的应用程序

./gradlew assembleRelease

我在日志中看到了我添加的新依赖项,但是当我尝试对其进行测试时:

react-native run-android --variant=release

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

到目前为止我一直在尝试什么:

  1. ./gradlew clean
  2. 删除我的构建文件夹并重新构建+重新启动我的计算机
  3. 删除我的android文件夹并重新构建+重启我的电脑
  4. 更改app/build.gradle+manifest.xml中的版本代码和版本名称

    每次尝试后我都从手机中删除了该应用

    我使用的是旧版本的旧密钥库

    我没有在使用 vsc 的 Visual Studio 即时通讯(我的代码是 React Native)

    这是我的 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 11
    versionName "2.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'
           }
         }
      }
   }

我的清单文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vitalacy.dashboard"
android:versionCode="11"
android:versionName="2.1.0">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="22" />

<application
  android:name=".MainApplication"
  android:allowBackup="true"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:theme="@style/AppTheme">

  <service android:name="com.evollu.react.fcm.MessagingService" android:enabled="true" android:exported="true">
  <intent-filter>
  <action android:name="com.google.firebase.MESSAGING_EVENT"/>
  </intent-filter>
  </service>

  <service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
  <intent-filter>
   <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
   </intent-filter>
   </service>
    <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:launchMode="singleTop"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
        <meta-data
      android:name="io.fabric.ApiKey"
      android:value="52e5d0cdae691f2b769e3a84eafeea147d7656b7"
      />
    <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
     <service
    android:name=".FirebaseServices.MyFirebaseMessagingService">
     <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
      </intent-filter>
     </service>
     <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_launcher"/>
      <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="my_default_channel"/>
      <service
    android:name=".FirebaseServices.FirebaseInstanceIDService">
      <intent-filter>
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
      </intent-filter>
        </service>
        </application>

        </manifest>

【问题讨论】:

    标签: android apk react-native-android


    【解决方案1】:

    解决方案:

    我通过删除android文件夹解决了它(当然要备份所有文件夹并返回成绩文件,keystore,local.propeties,manifest.xml等) 之后我做了这个我以前没有做过的命令

       "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"
    

    差不多就是这样

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-23
      • 1970-01-01
      • 1970-01-01
      • 2019-03-02
      • 2014-12-06
      • 2014-07-17
      • 1970-01-01
      相关资源
      最近更新 更多