0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Android Studio Kotlin エラー Unsolved Reference

Posted at

途中まで、ちゃんと動いていたのですが、いきなり、Unsolved Referenceのエラーが出てしまいました。6個くらいのActivityファイルがあるのですが、全部のファイルのR.layout.hogehoge_activityのところのRで赤くなってエラーが出ます。
Android Studioを初めて2週間の初心者です。
環境は
API28 revision 6
emulator-5554 Android 9
Android Studio 3.1.4
SDK tools 26.1.1
↑開発言語 Kotlin
たくさんアクティビティファイルがありますので、エラー内容がわかるであろう、MainActivityとbuild.gradleと、Manifestファイル、を書きました。
インターネットで調べたのですが、有益な情報が見つかりませんでしたので、詳しい方、お願い済ます。
エラー内容を記します。
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:processDebugResources'.

Failed to process resources, see aapt output above for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 0s
13 actionable tasks: 1 executed, 12 up-to-date

1つめのファイル MainActivity



package com.example.yusuke.mysql02

import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.preference.PreferenceManager
import android.view.View
import android.widget.EditText
import com.example.yusuke.mysql02.Grobal.grobalusername
import com.example.yusuke.mysql02.R.id.username
import android.widget.TextView
import android.widget.Toast
import com.android.volley.Request
import com.android.volley.toolbox.StringRequest
import kotlinx.android.synthetic.main.activity_main.*
import com.android.volley.Response
import com.android.volley.toolbox.JsonObjectRequest
import com.android.volley.toolbox.Volley
import org.json.JSONObject


class MainActivity : AppCompatActivity() {



    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

    }

    val jsonobj = JSONObject()

    fun nextactivity(v:View){

        jsonobj.put("username",username.text)
        jsonobj.put("password",password.text)

       val URL = "http://www.example.com/registeractivity.php"
       val que = Volley.newRequestQueue(this@MainActivity)


        val req = JsonObjectRequest(Request.Method.POST,URL,jsonobj,
                Response.Listener{
            response ->

                    Grobal.grobalexsist = response.toString()

                },Response.ErrorListener {
           Grobal.grobalexsist = "0"
        })

        que.add(req)


        var nametext : String = username.getText().toString()
        var passtext : String = password.getText().toString()

        Grobal.grobalusername = nametext
        Grobal.grobalpassword = passtext

        val intent = Intent(this,RegisteredActivity::class.java)
        startActivity(intent)

    }

    fun loginactivity(v: View){
        val intent = Intent(this,LoginActivity::class.java)
        startActivity(intent)
    }
}


2つ目のファイル build.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.yusuke.mysql02"
        minSdkVersion 20
        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 "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
    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'
    implementation 'com.android.volley:volley:1.1.1'

}


3つ目のファイル Manifestファイル

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.yusuke.mysql02">
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".LoginActivity" />
        <activity android:name=".RegisteredActivity" />
        <activity android:name=".choseuserActivity" />
        <activity android:name=".addfriend" />
        <activity android:name=".Message"></activity>
    </application>

</manifest>

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?