Import eclipse project into the latest Android Studio API

8

I did the project import from an eclipse app to Android Studio. The import occurred smoothly and the gradle was created. However, I notice that the visual components like EditText, ProgressBar, AppBar, Button are with an outdated look, of version 3.0 of android. I upgraded my minSdk to 15 and targetSdk to 23 and refreshed the gradle, but the visual components remain in the old APIs.

I also notice that whenever I create a new activity, I have the following pattern:

import android.app.Activity;
import android.os.Bundle;

public class TesteActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_teste);
    }
}

Activities only inherit from activity , not AppCompatActivity , as seen below in any project created in Android Studio:

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

By changing the inheritance of TesteActivity from Activity to AppCompatActivity , Android does not recognize the class. Recalling that this problem occurs only within the project imported from eclipse.

Is there any way I can import this old project to work with the latest Android Studio components / features?

    
asked by anonymous 03.05.2016 / 18:18

3 answers

1

After much searching, I was able to find where the problem was.

The AppCompatActivity class is only available from sdk tools 22, and my project was using 21. So I updated sdk tools from my build.grad (Module: app) and restarted Android Studio, getting as follows.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "org.spinsuite.base"
        minSdkVersion 14
        targetSdkVersion 23
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
}

After that, I went to the Build / Rebuild project menu. By doing this, just import import android.support.v7.app.AppCompatActivity; into the desired class and extend it from extends AppCompatActivity . I'm having some crash issues while executing the application, however in the project everything is ok. I believe this error is subject to another topic.

Related question: link
link
link

    
20.05.2016 / 18:13
6

Try to put

compile 'com.android.support:appcompat-v7:23.3.0'

Under "dependencies" in the build.gradle file

    
12.05.2016 / 23:10
1

Manually change the code to inherit from AppCompatActivity.

About widgets (EditText, Button, etc), check your styles.xml file. See which theme is set. Look for using some theme that inherits from Material.Theme

    
16.05.2016 / 00:40