修改.android地址
2018-08-16 16:48:06 mengbjy 阅读数 168

1. 最近AS仓库翻墙也经常不好用,还是换成国内的仓库。选阿里巴巴~~~的

2. 如图,更改项目根目录下的build.gradle内容为:

maven {
         name "aliyunmaven"
         url "http://maven.aliyun.com/nexus/content/groups/public/"
      }

项目根目录下的build.gradle

3. 两个都替换,区别:

1、 buildscript里是gradle脚本执行所需依赖,分别是对应的maven库和插件 
2、 allprojects里是项目本身需要的依赖。

http://maven.aliyun.com/mvn/view
2015-12-07 13:55:11 u013148839 阅读数 463

Rract Native Android 修改请求地址

注 这中方式 是吧 bundle 文件下载到 assets 目录下进行编译
在app目录下 build.gradle 文件中

final def TARGET_BUNDLE_DIR = 'app/src/main/assets/'
final def TARGET_BUNDLE_FILE = 'index.android.bundle'
final def DOWNLOAD_URL = 'http://localhost:8081/index.android.bundle?platform=android&dev=false&minify=true'




task downloadJSBundle << {
    def dir = new File(TARGET_BUNDLE_DIR)
    if (!dir.exists()) {
        dir.mkdirs()
    }
    def f = new File(TARGET_BUNDLE_DIR + TARGET_BUNDLE_FILE)
    if (f.exists()) {
        f.delete()
    }
    try {
        new URL(DOWNLOAD_URL).withInputStream{ i -> f.withOutputStream{ it << i }}
    } catch (Exception e) {
        e.printStackTrace()
    }

}

preBuild.dependsOn downloadJSBundle

2017-09-19 13:56:25 u014333053 阅读数 1542

由于之前的项目中一直在使用eclipse所以刚转用studio,一开始感受不是很爽,一脸懵逼,什么都找不到了(很菜的)。那么问题来了。
根据热心网友的建议一点点的配置好了studio的svn,配置上传svn需要忽略的一些文件,第二天就说svn地址换了,然后又是网上各种找换地址方法,一看还挺简单,如下:

VCS–>Suversion–>Relocate Working Copy

点击就出现了如下对话框:
这里写图片描述
然后网上说ToURL:后面写上新地址就OK了,but

Error relocating working copy: svn: E195009: The repository at ‘项目地址’
has uuid ‘******************’, but the WC has ‘*************************

报了上面的错误,又懵逼了,没遇到过,发现广大网友也很少遇到,还有说去workspace下去修改的,也是不行。

可行做法:

1、找到你项目的根目录,下面会有一个“.svn”文件夹,是个隐藏的文件夹,如果你没有显示隐藏的文件夹请自行设置,找到后删掉,
这里写图片描述

2、在studio中找到.idea–>vcs.xml,打开删除掉最后的“svn”

<mapping directory="" vcs="svn"/>
<mapping directory="" vcs=""/>

3、重新共享到新的地址就可以了,vcs –> import into version control –> share Project(subversion)
第一次会很慢就不用说了,share 完成后,再提交一次就OK了。

2016-01-21 17:58:04 lhy349 阅读数 19508

公司网络更新,服务器地址也随之发生了修改,本以为不会出现什么问题,结果在向服务器提交代码的过程中,才意识到SVN的服务器地址也发生了变化,首先尝试着删除了SVN Repositories 下的服务器地址,添加变更后的地址,无效!接着尝试着修改了Configure Branches配置信息,结果直接出现了如下图的现象


没办法,到必应上去找一下SVN服务器修改后,编译器的配置问题,一搜满屏的配置信息,点开一看全是SVN客户端和eclipse插件相关配置信息的文章,加上studio关键字再来一次,结果满屏的都是studio上SVN的安装信息。得了,自己动手丰衣足食,从studio上慢慢的找吧,最终找到了Relocate Working Copy,有点儿似曾相识的感觉,具体步骤如下图所示

在Android studio VCS-->Subversion目录下


进入Suversion-->Relocate Working Copy目录下


点击Relocate Working Copy 弹出如下对话框


只需要在To URL中输入变更后的SVN服务器地址即可完成COPY

如此简单的问题,还是小小的折腾了一下,因此在此记录一下,加深印象

2017-09-10 15:04:20 ad590802a 阅读数 799
//查看Wifi地址
public String getWifiIpAddress() {
    //获取wifi服务
    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    //判断wifi是否开启
    if (!wifiManager.isWifiEnabled()) {
        wifiManager.setWifiEnabled(true);
    }
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    int ipAddress = wifiInfo.getIpAddress();
    String ip = intToIp(ipAddress);
    Log.d("wuc", "wifiIp = " + ip);
    return ip;

}

//获取GPRS本地ip地址
public String getLocalIpAddress() {
    try {
        for (Enumeration<NetworkInterface> en = NetworkInterface
                .getNetworkInterfaces(); en.hasMoreElements();) {
            NetworkInterface intf = en.nextElement();
            for (Enumeration<InetAddress> enumIpAddr = intf
                    .getInetAddresses(); enumIpAddr.hasMoreElements();) {
                InetAddress inetAddress = enumIpAddr.nextElement();
                if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress()) {
                    Log.d("wuc", "gprs = " + inetAddress.getHostAddress().toString());
                    return inetAddress.getHostAddress().toString();
                }
            }
        }
    } catch (SocketException ex) {
        Log.e("WifiPreference IpAddress", ex.toString());
    }
    return null;
}

private String intToIp(int i) {

    return (i & 0xFF ) + "." +
            ((i >> 8 ) & 0xFF) + "." +
            ((i >> 16 ) & 0xFF) + "." +
            ( i >> 24 & 0xFF) ;
}
日志信息
09-10 14:58:06.288 12190-12190/com.example.administrator.newtext D/wuc: gprs = 10.96.76.60
09-10 14:58:15.488 12190-12190/com.example.administrator.newtext D/wuc: wifiIp = 192.168.1.103
修改wifi地址网上找的-------------------------
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo connectionInfo = wifiManager.getConnectionInfo();
List<WifiConfiguration> configuredNetworks = wifiManager
        .getConfiguredNetworks();
for (WifiConfiguration conf : configuredNetworks) {
    if (conf.networkId == connectionInfo.getNetworkId()) {
        wifiConf = conf;
        Toast.makeText(this, "11111", Toast.LENGTH_SHORT).show();
        break;
    }
}

Log.d("wuc", "wifiConfout = " + wifiConf);
try {
    setIpAssignment("STATIC", wifiConf);

    setIpAddress(InetAddress.getByName("192.168.0.110"), 24, wifiConf);

    setGateway(InetAddress.getByName("255.255.255.0"), wifiConf);

    setDNS(InetAddress.getByName("255.255.255.0"), wifiConf);

} catch (Exception e) {

    // TODO Auto-generated catch block
    e.printStackTrace();
}
Toast.makeText(this, "1121", Toast.LENGTH_SHORT).show();
wifiManager.updateNetwork(wifiConf); // apply the setting

public static void setIpAssignment(String assign, WifiConfiguration wifiConf)
        throws SecurityException, IllegalArgumentException,
        NoSuchFieldException, IllegalAccessException {
    Log.d("wuc", "wifiConfin = " + wifiConf);
    setEnumField(wifiConf, assign, "ipAssignment");
}

public static void setIpAddress(InetAddress addr, int prefixLength,
                                WifiConfiguration wifiConf) throws SecurityException,
        IllegalArgumentException, NoSuchFieldException,
        IllegalAccessException, NoSuchMethodException,
        ClassNotFoundException, InstantiationException,
        InvocationTargetException {
    Object linkProperties = getField(wifiConf, "linkProperties");
    if (linkProperties == null)
        return;
    Class laClass = Class.forName("android.net.LinkAddress");
    Constructor laConstructor = laClass.getConstructor(new Class[]{
            InetAddress.class, int.class});
    Object linkAddress = laConstructor.newInstance(addr, prefixLength);

    ArrayList mLinkAddresses = (ArrayList) getDeclaredField(linkProperties,
            "mLinkAddresses");
    mLinkAddresses.clear();
    mLinkAddresses.add(linkAddress);
}

public static void setGateway(InetAddress gateway,
                              WifiConfiguration wifiConf) throws SecurityException,
        IllegalArgumentException, NoSuchFieldException,
        IllegalAccessException, ClassNotFoundException,
        NoSuchMethodException, InstantiationException,
        InvocationTargetException {
    Object linkProperties = getField(wifiConf, "linkProperties");
    if (linkProperties == null)
        return;
    Class routeInfoClass = Class.forName("android.net.RouteInfo");
    Constructor routeInfoConstructor = routeInfoClass
            .getConstructor(new Class[]{InetAddress.class});
    Object routeInfo = routeInfoConstructor.newInstance(gateway);

    ArrayList mRoutes = (ArrayList) getDeclaredField(linkProperties,
            "mRoutes");
    mRoutes.clear();
    mRoutes.add(routeInfo);
}

public static void setDNS(InetAddress dns, WifiConfiguration wifiConf)
        throws SecurityException, IllegalArgumentException,
        NoSuchFieldException, IllegalAccessException {
    Object linkProperties = getField(wifiConf, "linkProperties");
    if (linkProperties == null)
        return;

    ArrayList<InetAddress> mDnses = (ArrayList<InetAddress>) getDeclaredField(
            linkProperties, "mDnses");
    mDnses.clear(); // or add a new dns address , here I just want to
    // replace DNS1
    mDnses.add(dns);
}

public static Object getField(Object obj, String name)
        throws SecurityException, NoSuchFieldException,
        IllegalArgumentException, IllegalAccessException {
    Field f = obj.getClass().getField(name);
    Object out = f.get(obj);
    return out;
}

public static Object getDeclaredField(Object obj, String name)
        throws SecurityException, NoSuchFieldException,
        IllegalArgumentException, IllegalAccessException {
    Field f = obj.getClass().getDeclaredField(name);
    f.setAccessible(true);
    Object out = f.get(obj);
    return out;
}

public static void setEnumField(Object obj, String value, String name)
        throws SecurityException, NoSuchFieldException,
        IllegalArgumentException, IllegalAccessException {
    Log.d("wuc", "wifiConfinin = " + obj);
    Field f = obj.getClass().getField(name);
    f.set(obj, Enum.valueOf((Class<Enum>) f.getType(), value));
}
但是这个wifi修改地址没成功。
提示:java.lang.NoSuchFieldException: ipAssignment  
难道是ipAssignment名称不对?
看网上说getField换成getDeclaredField 
提示:java.lang.NoSuchFieldException: No field ipAssignment in class Landroid/net/wifi/WifiConfiguration; (declaration of 'android.net.wifi.WifiConfiguration' appears in /system/framework/framework.jar)
不知道是哪错了求大神指导
没有更多推荐了,返回首页