All Products
Search
Document Center

Mobile Platform as a Service:Android Portal&Bundle Access Issues

Last Updated:Nov 24, 2023

This topic describes the common access issues of Android Portal&Bundle.

No network connection at compile time

When compiling files, if there is no network, it is likely to cause compilation failure. Perform the following steps to confirm that the network of the compilation environment is connected.

  1. Confirm that you are connected to the Internet.

  2. Confirm that no network proxy is connected, including browser proxy settings and third-party network proxy software.

  3. Verify that the IDE proxy is not set.

    idea 代理

  4. In the gradle.properties file, verify that the Gradle proxy is not set, that is, the systemProp.http.proxyHost and systemProp.http.proxyPort properties are not set. If you have specified the property, delete the property. gradle代理

Program compilation failed

If the program fails to compile, perform the following steps to troubleshoot and resolve the error:

  1. Make sure that the network in the compilation environment is properly connected based on the No network connection at compile time.

  2. Check the Gradle execution records to confirm that the added dependencies are valid.

  3. Check whether the GAV( group, artifact, version) parameters of the dependency are correctly set.

    // Reference the debug package group:artifact:version:raw@jar
    bundle "com.app.xxxxx.xxxx:test-build:1.0-SNAPSHOT:raw@jar"
    // Reference the release package group:artifact:version@jar
    bundle "com.app.xxxxx.xxxx:test-build:1.0-SNAPSHOT@jar"
    manifest "com.app.xxxxx.xxxx:test-build:1.0-SNAPSHOT:AndroidManifest@xml"
  4. In the built-in command line tools, run the following command to export Gradle execution records:

    // Before you run the command, make sure that the productflavor attribute is not defined. Otherwise, the command will fail to run. 
    // Run the following command to export execution records to the log.txt file. 
    gradle buildDebug --info --debug -Plog=true > log.txt
  5. View the record file exported in step 4. In the latest generated record, you will see a record similar to the following, indicating that the added dependency does not exist.

    Caused by: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find nebulacore-build-AndroidManifest.xml (com.alipay.android.phone.wallet:nebulacore-build:1.6.0.171211174825).
    Searched in the following locations:
    http://mvn.cloud.alipay.com/nexus/content/repositories/releases/com/alipay/android/phone/wallet/nebulacore-build/1.6.0.171211174825/nebulacore-build-1.6.0.171211174825-AndroidManifest.xml
         at org.gradle.internal.resolve.result.DefaultBuildableArtifactResolveResult.notFound(DefaultBuildableArtifactResolveResult.java:38)
         at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository$LocateInCacheRepositoryAccess.resolveArtifactFromCache(CachingModuleComponentRepository.java:260)
  6. Visit the HTTP link in this record (as shown in line 3 of the record listed in the previous step) and log in to view the Maven repository.

    Note

    You can view the account name and password required for login in the build.gradle file.

  7. Run the following command to refresh the gradle cache:

    gradle clean --refresh-dependencies
  8. If the Maven repository has corresponding dependencies, delete the Gradle cache in the personal directory and recompile. You can delete the Gradle cache as follows:

    • Run the following command in a system such as macOS, Linux, and Unix.

      cd ~
      cd .gradle
      cd caches
      rm -rf modules-2
    • In Windows, the default path is C:\Users \\{ username }\\.gradle\caches and the modules-2 folder is deleted.

Stuttering occurs during compilation

If the compilation process is stuck (wait for more than 20 minutes), you can perform the following steps to improve the compilation efficiency.

  1. According to the above steps, confirm that the compilation environment network is connected normally.

  2. Verify that the firewall is disabled.

  3. Make sure that the network configuration of the IntelliJ IDEA compiler is not enabled.

  4. In the code, load the Maven image in advance. For example, the following code shows how to load a Maven image from Alibaba Cloud.

     apply plugin: 'maven'
     buildscript {
         repositories {
             mavenLocal()
    
     // Start loading the Maven image first.
             maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
    
             maven {
                 credentials {
                     username "Use known user"
                     password "Use a known password "
                 }
                 url "http://mvn.cloud.alipay.com/nexus/content/repositories/releases/"
             }
         }
         dependencies {
             classpath 'com.android.tools.build:gradle:2.1.3'
             classpath 'com.alipay.android:android-gradle-plugin:2.1.3.3.3'
             classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
         }
     }
     allprojects {
         repositories {
             flatDir {
                 dirs 'libs'
             }
             mavenLocal()
             maven {
                 credentials {
                     username "xxxxxxxxx"
                     password "xxxxxxx"
                 }
                 url "http://mvn.cloud.alipay.com/nexus/content/repositories/releases/"
             }
             maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
         }
     }

Compilation fails and NullPointerException occurs

空指针异常After you download the configuration file and connect it to the private cloud, the compilation fails and an NullPointerException occurs. If you encounter such a problem, you generally need to check the fields in the config configuration file. Check whether 13 fields are missing and compare them with the file downloaded from the public cloud to check whether the field names are correct.

How to debug an application

You need to debug the code during the development process. This topic describes two debugging methods.

  • Start the application in debug mode

  • Debug the application after it runs

Start an application in debug mode

  • Scenarios

    You want to debug the initial code when the application starts, such as the initialization code at application init time.

  • Procedure

  1. Run the adb shell am start -W -S -D application package name /first startup page class name of the application command. For example, if the package name of mPaaS Demo is com.mpaas.demo and the first page class name of the application is com.alipay.mobile.quinox.LauncherActivity, you can use the command line adb shell am start -W -S -D com.mpaas.demo/com.alipay.mobile.quinox.LauncherActivity to start the application in debugging mode. The following figure shows the name of the first class to start.

    img

  2. After you run the command, the following dialog box appears.

  3. Set a breakpoint on the line of code that you want to debug, and then attach it to the process where the application is located, as shown in the figure.

    修改2.jpg

Debug an application after it is run

  • Scenarios

    Debugging is required after an event is triggered. For example, debugging is required only when you click a button or jump to a page.

  • Procedure

    After the application is running, click the Attach Process (process) button, or after you run the preceding command, click the Attach button to start debugging.

Precautions for using MultiDex in the mPaaS Portal&Bundle project

We recommend that you do not integrate Portal and Bundle to MultiDex, unless you are dealing with a single portal project and need to use multiDexEnabled true. If your bundle is too large, you can only split the bundle. Do not enable multidex support in the bundle.

How to clear the Gradle cache

Open the settings interface of the Gradle plug-in and click the Clean Cache button to delete all cached data of the Gradle plug-in.

插件设置界面

How to upgrade to the latest Gradle plugin

Note

This section applies only to 10.1.68 series baselines. For more information about baselines of this version, see Baselines overview and 10.1.68 series baselines release notes.

At present, Google's official Android Gradle Plugin is 3.5.x version.

mPaaS also provides 3.5.x version of the plug-in as an adaptation to support Google Android Gradle Plugin 3.5.3 and Gradle 6.2 APIs.

Introduction of changes

  1. You only need to add the following dependencies to introduce our plug-ins. You do not need to introduce Android Gradle Plugin official plug-ins because of the dependency transfer relationship.

    dependencies {
    classpath 'com.alipay.android:android-gradle-plugin:3.5.18'
    }
  2. The version of Gradle Wrapper needs to be upgraded to 5.6 or above, and it is recommend to use 6.2.

Changes in usage

  • No longer need to use apply plugin:'com.android.application'

    • If you are a portal project, you only need to use the apply plugin:'com.alipay.portal'.

    • If you are a bundle project and need to delete apply plugin:'com.android.application', you only need to use the apply plugin:'com.alipay.bundle'.

    • If you are a library project and want to delete apply plugin:'com.alipay.library', use only the apply plugin:'com.android.library.

  • If you use the latest stable version of Android Studio 3.5 or later, you need to add android.buildOnlyTargetAbi=false to your gradle.properties.

  • Since our wireless bodyguard component does not support V2 signature for the time being, if you need to use Android Studio to debug and install your APK, you need to disable V2 signature. If you use the command line to build and your minSdkVersion is greater than or equal to 24, you also need to disable V2 signature. You can disable V2 signatures as follows:

    v2SigningEnabled false

Important

After clearing the cache, you need to observe and confirm whether the applet and H5 work normally.