简体   繁体   中英

Android problems when import library project using IntelliJ

I am not sure why I cannot import the android.support.v7.app.ActionBarActivity class. I looked at and followed the steps described in this question to change the jar file of the project. However in the solution the first step was to delete the jar file that was already there, I however did not have that file. I am not using gradle.

This is code I got from the android tutorial.

    package com.example.myapp;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.ActionBarActvity;

public class DisplayMessageActivity extends Activity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_display_message);

        }
}

The error that comes up first is

Error:(5, 30) java: package android.support.v7.app does not exist

In the manifest also wrote this line.

<uses-sdk android:minSdkVersion="7"/>

I assume this is okay because I would need to make sure that v7 stuff is supported. As mentioned in the title I am using IntelliJ.

在依赖关系的build.gradle中添加它

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

If you are using IntelliJ IDEA and not Android Studio (gradle based), you should add the library by going to File > Project Structure

then go to your module, tab Dependencies, and add the jar file from there.

Jar files in libs are not automatically added in IntelliJ, you have to manually add them as dependencies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM