2

Could you help me with android studio.

I am new in android studio. I now installed java version 8 and android studio->opened new Project, but I have an error, I have everytime in activity_main.xml "Waiting for build to finish". I don't know why.

I am very thankfull if you can help me.

This is a Code:

package com.example.janyl.meinersteapp;

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);
    }
}

And this is a loyout

>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout    xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivityy"
tools:showIn="@layout/activity_main_activityy">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

and it is a screen[https://i.stack.imgur.com/4wX23.png]

it is build.gradle file

    def var = apply(plugin: 'com.android.application')

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.example.janyl.meinersteapp"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-  layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
KG. Boys
  • 43
  • 6

1 Answers1

2

In order to show Android Studio preview, the gradle should be synced or already having a successful build to show the Android Preview.

It says you should wait for the build to finish the task.

You can manage the tasks at the bottom of the Android Studio as follows if something is paused or not finished:

enter image description here

Or, try to rebuild the project from Build -> Rebuild project and if there were no issues/problems in the project, you should be able to see the preview after that.

ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
  • :(it didn't help. It says 7 errors in activity_main.xml . But I didn't do anything – KG. Boys Oct 01 '18 at 19:06
  • Because there are issues in your layout. That's why it cannot load the Preview. Would you paste the logcat or logs where those errors located in your question? – ʍѳђઽ૯ท Oct 01 '18 at 19:07
  • I opened a new project and there is the same problem. it said "Preview is unavailable a successful project sync" :( – KG. Boys Oct 01 '18 at 19:14
  • That's exactly what I already explained in my answer. There are probably some issues in your project which you should paste the logcat or the logs which causes the issue. Can't help without checking logs or codes. – ʍѳђઽ૯ท Oct 01 '18 at 19:15
  • 1
    Check this link: https://stackoverflow.com/questions/29045129/android-java-exe-finished-with-non-zero-exit-value-1 – ʍѳђઽ૯ท Oct 01 '18 at 19:54
  • ok, thanks. Is ndk important for android studio? I have linux mint 32 bit and I diidn't find ndk for 32 bit. I think it is the problem..But I am not sure. I have still the same problem – KG. Boys Oct 03 '18 at 19:51
  • It is used to code [with c++](https://developer.android.com/ndk/) for Android. I don't use it honestly, I prefer the kotlin nowadays. Up to you BTW. – ʍѳђઽ૯ท Oct 03 '18 at 20:03
  • oh ok, then I don't know what the problem in my case is:(( – KG. Boys Oct 03 '18 at 20:30
  • What is the issue now? I don't see any issues with the ndk. Those were just layout issues which can be fixed easily, please clarify me with a screenshot of the errors so that I can help you. – ʍѳђઽ૯ท Oct 03 '18 at 20:32
  • [ https://i.stack.imgur.com/0GEQ4.png ] it says everytime "Waiting for build to finish". I don't know why.. – KG. Boys Oct 03 '18 at 20:46
  • What version of Android Studio you are using? This happens because **there are multiple issues in your codes and you'll need to fix them first**. Then, if you run the app, the preview will show up **after a successful build** just like I said in my answer. – ʍѳђઽ૯ท Oct 03 '18 at 20:48
  • I use android version 3.2. I downloaded it 2 days ago. But I didn't write the code. I opened the new project and this code was here. I didn't do anything. I did the same as here : https://www.youtube.com/watch?v=bl8Q3Mi1x4I . I am new in android and in programming.. – KG. Boys Oct 03 '18 at 20:59
  • Did you try suggested answers in [this link](https://stackoverflow.com/questions/29045129/android-java-exe-finished-with-non-zero-exit-value-1)? If you still see the exit with 0 zero error, show me your build.gradle file. – ʍѳђઽ૯ท Oct 03 '18 at 21:05
  • yes, I tried suggested answer in the link. but didn't help. I added build.gradle in my question – KG. Boys Oct 03 '18 at 21:20
  • I just saw. There seems to be no problem with that, can you please check this link too : https://stackoverflow.com/a/40981824/4409113 This should probably help. – ʍѳђઽ૯ท Oct 03 '18 at 21:22
  • Yes I tried it yesterday. I changed to my jdk location which version I installed. but it didn't help – KG. Boys Oct 03 '18 at 21:38