栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Android(9) Unidbg添加SpringBoot Web服务

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Android(9) Unidbg添加SpringBoot Web服务

文章目录
    • 0. Unidbg删除unidbg-ios模块
    • 1. 添加Server模块
      • 方法① unidbg作为模块引入
      • 方法② Web作为模块引入
    • 2. 配置Server模块
    • 3. 编写Unidbg代码
    • 4. 修改SpringBoot配置、服务
    • 项目传至Git

0. Unidbg删除unidbg-ios模块

项目结构中删除unidbg-ios模块
本地删除unidbg/unidbg-ios文件夹
unidbg-parent模块(根目录unidbg)的pom文件中删除unidbg-ios

1. 添加Server模块 方法① unidbg作为模块引入

IDEA新建SpringBoot项目

从已存在的模块中导入Unidbg

方法② Web作为模块引入

IDEA打开Unidbg项目,新建SpringBoot模块

2. 配置Server模块

修改pom.xml文件,添加依赖

    

        
            org.springframework.boot
            spring-boot-starter-web
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        


        
            com.github.zhkl0228
            unidbg-android
            0.9.7-SNAPSHOT
            compile
        

        
            com.github.zhkl0228
            unidbg-api
            0.9.7-SNAPSHOT
            compile
        
        
            net.dongliu
            apk-parser
            2.6.10
            compile
        
        
            com.github.zhkl0228
            unidbg-dynarmic
            0.9.7-SNAPSHOT
            compile
        
        
            com.github.zhkl0228
            unidbg-hypervisor
            0.9.7-SNAPSHOT
            compile
        
        
            com.github.zhkl0228
            unidbg-kvm
            0.9.7-SNAPSHOT
            compile
        
        
            com.github.zhkl0228
            unidbg-unicorn2
            0.9.7-SNAPSHOT
            compile
        
    

版本号进行相应的更改

在pom中添加构建配置

    
        
            
                src/main/java
                
                    ***.so
                
            
        
    
3. 编写Unidbg代码

正常在WebServer的src目录中编写Unidbg代码即可。
可以将APK和so文件放在类的同目录,引用文件时使用以下代码:

new File(MainActivity.class.getResource("libnative.so").getFile())
4. 修改SpringBoot配置、服务

修改src/main/resources/application.properties文件改为src/main/resources/application.yml
添加SpringBoot配置

server:
  port: 7788

新建服务类server.HelloServer,代码如下

@RestController
public class HelloServer {
    @RequestMapping("/hello")
    public String hello() {
        return "Hello World";
    }
}

测试服务可以正常开启

新建一个Controller,新建对象模拟执行返回结果即可

项目传至Git

Clone下来后
方法①需要重新导入Unidbg模块,并再次同步maven
方法②同理

resources文件夹作为Resources Root标识会不见,重新设置一下即可,暂未发现其他问题

附项目结构

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/940220.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号