Gizwits platform android source code cannot be run in android studio during secondary development

Solution: The Android source code of the Gizwits platform cannot be run in Android studio during secondary development

1. Phenomenon

Due to learning needs, on the basis of almost zero Android development knowledge, with the help of Gizwits cloud platform to generate the required function code package. However, when importing into Android Studio (version 3.6), it cannot be run. The phenomenon is that the run button is gray and there is no item in the Edit Configuration box.

2. Modify it step by step

2.1. When you open the file for the first time, it has been in the loading state, as shown in the following figure:
Insert picture description here
sync has been in the Download state, do not wait for the fluke. . .

Reason: Domestic access to jcenter is too slow, or even unable to connect, it will report various errors about dependent update failure. In the past, oschina (that is, open source China) provided the jcenter mirror address, but unfortunately, for various reasons, the service has recently been discontinued.

Solution: https://blog.csdn.net/ScarletMeCarzy/article/details/78471446
Tip: After the modification is completed, exit AS and re-enter.

The following is my modified code:

File location build.gradle(located in the AndroidStudio folder instead of the app folder)
Note: In the code: 3.6.0 of classpath 'com.android.tools.build:gradle:3.6.0' is explained in 2.2, which varies from machine to machine (software changes automatically ).

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.0'

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

allprojects {
    repositories {
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

2.2 Gradle version matching problem (I have been stuck here for a long time) (the gray button becomes operational after completing this step)
This is a critical step. The following official website can find the correspondence between gradle plugin (tools.build) and gradle version number:
https://developer.android.google.cn/studio/releases/gradle-plugin#updating-plugin
Explain: other places on the Internet The solutions I found were all manually downloaded, but after downloading according to what I said online, I still get sync error:
Failed to apply plugin [id 'com.android.application'] The
final solution is: open Files—Project Structure and select the version to let Automatic computer download (the Alibaba Cloud image has been switched to in the first step, so the download speed takes off)

Below is my correspondence (note that the NDK default path is not set, you need to set up their own):
Insert picture description here
Insert picture description here
2.3 to do the above two steps, sync compiled successfully, then the USB connection phone (the phone is turned on USB debugging mode) Click Run, a warning
Insert picture description here
note: This warning cannot be ignored, otherwise the mobile app will flash back.
Reason: The API in the configuration file has expired, and the expired API should be modified.
Reference: https://blog.csdn.net/weixin_40845165/article/details/89213528
Reference: https://blog.csdn.net/weixin_44135826/article/details/105201233?fps=1&locationNum=2 The
following is my code:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '29.0.3'     //这里是我下载的工具版本,看自己android studio下载的什么版本,最后会讲在哪里看自己的buildTools版本
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "com.gizwits.opensource.appkit"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "2.5.1.072715"
        multiDexEnabled true
        ndk {
            abiFilters "armeabi-v7a", "x86", "armeabi"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:25.3.1'
    implementation files('libs/BLEasyConfig.jar')
    implementation files('libs/easylink2.0.jar')
    implementation files('libs/GizWifiSDK.jar')
    implementation files('libs/jpush-android-2.1.5.jar')
    implementation files('libs/Lark7618SDK_noudp1606031910_0101.jar')
    implementation files('libs/libammsdk.jar')
    implementation files('libs/libForEElink.jar')
    implementation files('libs/LSFSK_1.0.jar')
    implementation files('libs/ltlink2.jar')
    implementation files('libs/mta-sdk-1.6.2.jar')
    implementation files('libs/OneShotConfig.jar')
    implementation files('libs/open_sdk_r5756.jar')
    implementation files('libs/pushservice-5.6.0.30.jar')
    implementation files('libs/simpleconfigwizardlib.jar')
    implementation files('libs/xUtils-2.6.14.jar')
    implementation files('libs/zxing.jar')
    implementation 'com.android.support:design:25.3.1'
    implementation 'com.yanzhenjie:permission:1.0.5'
}

2.4 Run error again after modification:
Insert picture description here
Reason: low version error
Solution: Comment out the 6th line in the AndroidManifest.xml file (move the cursor to the code and press Ctrl + / to comment), as shown in the figure below (already commented):
Insert picture description here

In summary, success.

3. References and thanks

This article mainly refers to the article of the author CS sweeping monk : Solution: Modify the original android code of the Gizwits SOC scheme, and the Android virtual machine successfully runs the Gizwits APP .

Published an original article · Like1 · Visits 27

Guess you like

Origin blog.csdn.net/qq_42457131/article/details/105531865