File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 1
- #android studio的debug和release模式下使用不同的Http前缀进行测试与正式环境的自动切换
1
+ # android studio的debug和release模式下使用不同的Http前缀进行测试与正式环境的自动切换
2
2
3
3
4
- 我写代码的时候一般会使用两个环境 ,一个是测试环境,一个是正式环境并且这个两个环境的http请求连接地址的前缀肯定是不一样的
4
+ 在项目开发过程中一般会使用两种Url环境 ,一个是测试环境,一个是正式环境并且这个两个环境的http请求连接地址的前缀肯定是不一样的。
5
5
6
6
例如,测试环境我们使用http://192.168.1.1:8080作为请求前缀
7
7
11
11
12
12
安卓的机制中有一个变量用来区分正式和测试环境,我们可以拿到这个变量然后对他进行判断就可以自动去根据模式来改变url地址前缀
13
13
14
- ##使用变量BuildConfig.DEBUG(debug模式返回true,release模式返回false)
14
+ ## 使用变量BuildConfig.DEBUG(debug模式返回true,release模式返回false)
15
15
16
16
位置:app->build->generated->source->buildCofig->debug->BuildConfig文件,如图:
17
17
18
- 在用的时候我们会定义一个全局的HttpUrl.myurl
18
+ #### 在用的时候我们会定义一个全局的Url地址。
19
19
20
- ###我们写一个三木运算就可以得到想要的分环境的不同url
20
+ ### 我们写一个三木运算就可以得到想要的分环境的不同url
21
21
### BuildConfig.DEBUG? 测试地址: 正式地址
22
22
23
23
这样使用release打包出来的应用就是会使用正式的url前缀,测试的时候run app默认是使用就是debug,所以就解决了使用地址错的的问题了
Original file line number Diff line number Diff line change 1
1
---
2
2
layout: page
3
3
title: "About"
4
- description: "Hey, this is Hux ."
4
+ description: "Hey, this is Tyxs ."
5
5
header-img: "img/about-bg-walle.jpg"
6
6
multilingual: true
7
7
---
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <module type =" WEB_MODULE" version =" 4" >
3
+ <component name =" NewModuleRootManager" inherit-compiler-output =" true" >
4
+ <exclude-output />
5
+ <content url =" file://$MODULE_DIR$" />
6
+ <orderEntry type =" inheritedJdk" />
7
+ <orderEntry type =" sourceFolder" forTests =" false" />
8
+ </component >
9
+ </module >
You can’t perform that action at this time.
0 commit comments