eclipse项目转到Android studio的步骤和问题

本文解决了Android Studio中常见的三个问题:版本不一致导致的编译错误、Couldnotfindmethodandroid()异常及中文乱码问题,并提供了详细的解决步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题一:版本问题:项目中的版本和IDE的版本不一样

解决方案:
File->Project Structure->app->Properties
修改sdk版本和build tools版本,为编译器现有的版本

问题一、解决Could not find method android() for arguments问题

在导入新项目的时候,发现一直有个bug存在,编译出现如下错误:

Error:(23, 0) Could not find method android() for arguments [****] on root project '****' of type org.gradle.api.Project.

最终解决方案:打开项目gradle目录如下:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.novoda:bintray-release:0.3.4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'
}
dependencies {
}

将其中的

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'
}

删除或注释掉后重新编译通过。

问题二、android studio中文乱码各种情况的解决办法

Android Studio导入Eclipse的android项目java文件出现中文乱码,比如中文注释,中文提示等乱码,这一般是Eclipse中是gbk,到了Android Studio后默认utf-8格式打开的缘故。

1、注释中文出现乱码

解决方法:在 Android Studio 的设置菜单中找到修改编码的地方。如下:
File > Settings > Editor > File Encodings 里 Project Encoding 改为 GBK,为了统一规范,我也将其它 Encoding 项也设置为 GBK了。

2、用虚拟机运行应用时APP界面文字乱码。

解决办法:在Gradle Scripts -> build.gradle中的如下下图位置添加:
android{compileOptions.encoding=”GBK”}

这里写图片描述
注意,别加到project的bulid.gradle里去。

3、前两项做完之后关闭Android Studio重启运行乱码就会变成中文

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值