zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

【Android 插件化】VirtualApp 编译运行 ( VirtualApp 简介 | 配置 VirtualApp 编译环境 | 编译运行 VirtualApp 官方示例 )

Android配置官方插件 环境 运行 示例 简介
2023-09-14 09:07:30 时间





一、VirtualApp 简介



VirtualApp GitHub 地址 : https://github.com/asLody/VirtualApp

在这里插入图片描述





二、配置 VirtualApp 编译环境




1、Android Studio 3.0


编译 VirtualApp , 需要使用 Android Studio 3.0 版本的 IDE , 否则编译会失败 ;

参考博客 :

最终使用 Android Studio 3.0 , 完成了 VirtualApp 的编译 ;


2、NDK 版本 ( Android NDK r10e )


该项目在 2017 年停止维护 , 使用的开发环境 , SDK , NDK 都比较老 , 这里也要使用相应版本的环境配置 , 尤其是 NDK 比较复杂 , 如果版本使用的不对 , 直接报错 ;

这里使用 Android NDK r10e(2015 年 5 月)的版本 ;

当前 SDK 中已经不支持 16 以下的 NDK 版本 ;

在这里插入图片描述

如果要下载老版本的 NDK , 要到 https://developer.android.google.cn/ndk/downloads/older_releases.html 页面下载 , 下载 Android NDK r10e(2015 年 5 月)下的 Windows 64 位 android-ndk-r10e-windows-x86_64.zip 版本 ; ( 点击上述链接也可以下载 )

在这里插入图片描述

下载后解压 , 并在 local.properties 配置文件中配置 ndk 路径 ;

ndk.dir=D\:\\001_Develop\\001_SDK\\Sdk\\ndk\\android-ndk-r10e-windows-x86_64\\android-ndk-r10e
sdk.dir=D\:\\001_Develop\\001_SDK\\Sdk

参考博客 【错误记录】Android Studio 编译报错 ( VirtualApp 编译 NDK 报错 | Error:A problem occurred configuring project ‘: ) ;


3、配置远程仓库


配置远程仓库 : 如果不配置 , 无法下载编译所需的依赖库 , 翻了墙也会下载失败 ;

在根目录下的 build.gradle 中的 buildscript.repositoriesallprojects.repositories 中 , 添加如下两个远程仓库 , 否则编译环境依赖库下载都会出现问题 ;

        google()
        mavenCentral()

配置完毕后的样式 :

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

buildscript {
    repositories {
        jcenter()
        google()
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        //classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.android.tools.build:gradle-experimental:0.11.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

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




三、编译运行 VirtualApp 官方示例



上述配置完成后 , 即可成功编译 VirtualApp 官方示例 ;

在这里插入图片描述

运行效果 :

在这里插入图片描述

选择一款应用 , 安装该应用 ;

在这里插入图片描述

安装完毕后的应用 ;

在这里插入图片描述

运行插件应用后的效果 ;

在这里插入图片描述





四、编译好的 VirtualApp 官方源码



该经过了修改 , 可以运行 ;

下载地址 : https://download.csdn.net/download/han1202012/33034575





总结 ( 编译配置如下 )


在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

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

buildscript {
    repositories {
        jcenter()
        google()
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        //classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.android.tools.build:gradle-experimental:0.11.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

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