All Products
Search
Document Center

Mobile Platform as a Service:FAQ

Last Updated:Nov 21, 2024

Check the following FAQ list, then click the specific questions to view the answer.

No network connection when you compile

When you are compiling files, if there is no network, the compilation may fail. Follow the steps to confirm that the network of compilation environment is connected.

  1. Confirm that the Internet is connected.

  2. Confirm that the network proxy is not connected, including browser proxy settings and third-party network proxies.

  3. Confirm that the IDE proxy is not configured.

    idea proxy

  4. In the gradle.properties file, confirm that the Gradle proxy is not configured. That is, the systemProp.http.proxyHost and the systemProp.http.proxyPort attribute is not configured. If configured, you can delete the relevant attribute.

    gradle proxy

Program compilation failed

If program compilation failed, you can make troubleshooting and solutions by following the steps.

  1. According to the preceding steps, you can confirm that the network of compilation environment is connected.

  2. Check the Gradle execution log to confirm if the added dependency is valid.

  3. Check if the dependent GAV parameters including group, artifact, and version are configured correctly.

    //Reference the debug pack group:artifact:version:raw@jar
    bundle "com.app.xxxxx.xxxx:test-build:1.0-SNAPSHOT:raw@jar"
    //Reference the release pack 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 command line tool built in the system, execute the following command to export the Gradle execute logs:

    // Before executing the command, confirm the undefined productflavor attribute. Otherwise, the command will fail to run.
    // The following command will export the execution log to the log.txt file.
    gradle buildDebug --info --debug -Plog=true > log.txt
  5. Check the log file exported from the fourth step. In the latest log, you will see the following record, which means 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 log and log on to check the Maven library. For example, the http link can be the third line in the log listed in the preceding step.

    Note

    In the build.gradle file, you can check the account name and password that you need to provide when you log on.

  7. Execute the following command to refresh the gradle cache.

    gradle clean --refresh-dependencies
  8. If the Maven library has a relevant dependency, delete the Gradle cache under your personal directory, then recompile.

    The method of deleting the Gradle cache is as follows:

    • In the system such as macOS, Linux, and Unix, run the following commands:

      cd ~
      cd .gradle
      cd caches
      rm -rf modules-2
    • In the Windows system, by default, the path will be located to C:\Users\\{Username}\\.gradle\caches. Delete the modules-2 folder.

Access problem during compilation

If there is an access problem during compilation, (you have waited for more than 20 minutes) you can improve the compilation efficiency by following the steps.

  1. According to the preceding steps, you can confirm that the network of compilation environment is connected.

  2. Confirm that the firewall is closed.

  3. Confirm that the network configuration of the IntelliJ IDEA encoder is inactivated.

  4. In the code, load Maven images in advance. See the following code example of Maven images loaded by Alibaba Cloud.

apply plugin: 'maven'
buildscript {
    repositories {
        mavenLocal()

// Load Maven images at first
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}

        maven {
            credentials {
                username "Use the known user"
                password "Use the 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/'}
    }
}

When you access to Apsara Stack, after downloading configurations and accessing to mPaaS, compilation is rejected and NullPointerException occurs

Null pointer exceptionIn general, this is the problem of the configuration file, namely, the conf file. You need to check the fields. Check if any of the thirteen fields are missing. Compare with the files downloaded from the public cloud, and confirm if the field name is correct.

How to debug applications

During the development, you need to debug codes. This topic describes two debug methods.

  • Start the application through the debug mode

  • Run the application, then start debugging

Start the application through the debug mode

  • Use cases:

    The initial code that you want to use when the debug application launched. For example, initialize the code during application init.

  • Procedures:

  1. Execute the command adb shell am start -W -S -D application pack name/The type name of the first page launched by the application. For example, the pack name of the mPaaS Demo is com.mpaas.demo, and the type name of the first page launched by 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 launch the application through the debug mode. See the following picture for the first type name launched. img

  2. After the command is executed, the following dialogue box will appear on the mobile phone.

  3. Set the breakpoint to the code line you want to debug. Then attach the breakpoint to the process where the application is. See the following picture.

    修改2.jpg

Run the application, then start debugging

  • Use cases:

    Start debugging after you trigger an event. For example, only when you click a button or redirect to a page, you need to debug.

  • Procedures:

    After running the application, click the attached Process button. Or after executing the preceding command, click the attached button, then start debugging.

Precautions for using MultiDex in the mPaaS Portal and Bundle projects

Portal and Bundle are not suggested to intervene in the MultiDex. Unless you are in the single portal project, and need to use the multiDexEnabled true.If your Bundle is too big, you can only continue by the method of splitting the bundle. Do not activate the multidex support in the bundle.

How to clear the Gradle cache

Open the configuration page of the Gradle plug-in, then click Clean Cache button to delete all the cache data of the Gradle plug-in.

image

Upgrade to the latest Gradle plug-in

Note

The content of this section is only applicable for 10.1.68 baselines. For more information about the baseline of this version, see Introduction to the baseline and Launch instructions of 10.1.68 baselines.

The version of the Android Gradle Plugin provided by Google is 3.5.x at the moment.

mPaaS also provides the plug-in of 3.5.x version as the adapter, which supports the APIs of Google Android Gradle Plugin 3.5.3 and Gradle 6.3.

Change in the access methods

  1. You only need to import our plug-ins by adding the following dependency instead of importing the official plug-in of Android Gradle Plugin. Because of the dependency transmission, the plug-in will be imported automatically.

    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 later versions. Version 6.3 is recommended to use.

Change in the usages

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

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

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

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

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

  • Our wireless security components do not support V2 signatures at the moment. Thus, if you need to use Android Studio debugging and install your APK, you need to disable V2 signatures. If you use the command line for creation, and your minSdkVersion is greater than or equal to 24, you need to disable V2 signatures as well. See the following method of disabling V2 signatures:

    v2SigningEnabled false

Important

After clearing the cache, you need to check if the mini program and HTML5 work.

Camera cannot be turned on through the input file label in Huawei 10 System

There are some differences between the implementations of Huawei 10 system URI and the standard Android. Thus, you may meet problems such as failing to turn on the camera in Huawei 10. You need to execute the following steps to solve this problem.

1. Upgrade baselines

  • If you are using 32 baselines, you need to upgrade the baseline to 10.1.32.18 or later.

  • If you are using 60 baselines, you need to upgrade the baseline to 10.1.60.9 or later.

  • If you are using 68 baselines, you need to upgrade the baseline to 10.1.68-beta.3 or later.

2. Configure FileProvider

You can reuse your current FileProvider or create a new FileProvider.

  1. Create a new Java class to inherit the FileProvider.

    import android.support.v4.content.FileProvider;
    public class NebulaDemoFileProvider extends FileProvider {
    }
  2. Create a new nebula_fileprovider_path.xml in res/xml.

    <?xml version="1.0" encoding="utf-8"?>
    <paths xmlns:android="http://schemas.android.com/apk/res/android">
     <external-path name="external" path="."/>
    </paths>
  3. Add configurations in AndroidManifest.

    <provider
     android:name="com.mpaas.demo.nebula.NebulaDemoFileProvider"
     android:authorities="com.mpaas.demo.nebula.provider"
     android:exported="false"
     android:grantUriPermissions="true">
     <meta-data
         android:name="android.support.FILE_PROVIDER_PATHS"
         android:resource="@xml/nebula_fileprovider_path" />
    </provider>
Note

Here the value of android:authorities, namely com.mpaas.demo.nebula.provider is an mPaaS sample code. You need to configure by yourself based on your applications. And the value cannot be configured as com.mpaas.demo.nebula.provider, which will have conflicts with other mPaaS applications.

3. Implement the H5NebulaFileProvider

  1. Create a new Java class, then implement the H5NebulaFileProvider and the getUriForFile method. In this method, you can call the implemented FileProvider to generate URI.

    public class H5NebulaFileProviderImpl implements H5NebulaFileProvider {
     private static final String TAG = "H5FileProviderImpl";
    
     @Override
     public Uri getUriForFile(File file) {
         try {
             return getUriForFileImpl(file);
         } catch (Exception e) {
             H5Log.e(TAG, e);
         }
         return null;
     }
    
     private static Uri getUriForFileImpl(File file) {
         Uri fileUri = null;
         if (Build.VERSION.SDK_INT >= 24) {
             fileUri = NebulaDemoFileProvider.getUriForFile(LauncherApplicationAgent.getInstance().getApplicationContext(), "com.mpaas.demo.nebula.provider", file);
         } else {
             fileUri = Uri.fromFile(file);
         }
         return fileUri;
     }
    }
  2. Register the H5NebulaFileProvider.

    After you complete the mPaaS initialization, register the H5NebulaFileProvider before you start the off-line pack. Register once will take effect globally.

    H5Utils.setProvider(H5NebulaFileProvider.class.getName(), new H5NebulaFileProviderImpl());

How to depend on and use mPaaS in library?

While using mPaaS, a module needs to be reused sometimes. The reuse is implemented by adding the module as a dependency. This section illustrates this method with an example of reusing scan module.

Prerequisites

The project has been accessed to mPaaS in native AAR mode.

Procedure

  1. Create an Android Library type scan module in the project.

  2. In the build.gradle file of the newly created scan module, add the following codes api platform("com.mpaas.android:$mpaas_artifact:$mpaas_baseline"). The example is as follows:

     dependencies {
         ……
         //This line is necessary when using mPaaS in the module.
         api platform("com.mpaas.android:$mpaas_artifact:$mpaas_baseline")
    
         ……
      }
  3. Install scan component for scan module by Android Studio mPaaS plug-in. The directory is : mPaaS > Native AAR mode > Configure/Update component > Start configuration. After the installation, the scan component will automatically load.

  4. Configure App main project.

     plugins {
         id 'com.android.application'
    
         ......
         // baseline.config (baseline) must be added in the build.gradle file of app module.
         id 'com.alipay.apollo.baseline.config'
     }
  5. Call module.

    Import scan module where it is used.

     dependencies {
         api platform("com.mpaas.android:$mpaas_artifact:$mpaas_baseline")
    
         ....
         api project(':scan')//scan module
     }

How to fix 608 errors at runtime or native errors with libsgmain

  1. If an exception occurs during runtime, search for the keyword SecExcetpion in the Android Studio runtime log, and find that there is a 608 error code or a native error of libsgmain, you can follow the steps below to troubleshoot.

    1. Drag and drop the APK directly into Android Studio and check if the targetSdkVersion in the Androidmenifest file is a version between 26-28.1

    2. Check if the res/drawable/yw_1222.jpg file exists.

      • Check the config file for Base64.

      • Check if the Gradle plugin baseline.update or baseline.config is applied.2

    3. Check META-INF for three files, CERT.SF, MANIFEST.MF, and CERT.RSA.

      1. Turn on v1SignEnabled in app/build.gradle.

      2. Whether there is apply plugin: 'com.alipay.apollo.optimize' in build.gradle in the project root directory.3

    After performing the above check steps and confirming that the result is correct, it means that there is a problem with the signed APK package uploaded on the console. If the signature is incorrect, the APK package needs to be re-uploaded.