最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Android App Failed to Build, Error: ParseError at [row,col]: [17,3] - Stack Overflow

programmeradmin3浏览0评论

I need help with the current state of my app because I recently fixed Syntax errors that before gave me noticeable errors. I need to make sure this build of the app is working correctly, before I continue working on it. I am currently trying to make a simple to-do app, but am having a hard time. I am attempting to make this build work, so I can add more features to the app and make sure that it works correctly.

package com.example.firstapriltemplate

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activitypose.setContent
import androidx.activity.enableEdgeToEdge
import androidxpose.foundation.layout.fillMaxSize
import androidxpose.foundation.layout.padding
import androidxpose.material3.Scaffold
import androidxpose.material3.Text
import androidxpose.runtime.Composable
import androidxpose.ui.Modifier
import androidxpose.ui.tooling.preview.Preview
import com.example.firstapriltemplate.ui.theme.FirstAprilTemplateTheme
import androidxpose.foundation.layout.Column
import androidxpose.foundation.layout.Row
import androidxpose.material3.OutlinedTextField
import androidxpose.runtime.mutableStateOf
import androidxpose.runtime.remember
import androidxpose.ui.text.font.FontWeight
import androidxpose.ui.unit.dp
import androidxpose.ui.unit.sp
import androidxpose.material3.Surface
import androidxpose.material3.MaterialTheme
import androidxpose.runtime.getValue
import androidxpose.runtime.setValue
import java.util.concurrent.BlockingDeque



class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            App()
            FirstAprilTemplateTheme {
                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                    Greeting(
                        name = "Android",
                        modifier = Modifier.padding(innerPadding)
                    )
                }
            }
        }
    }
}

@Composable
fun App(){
    var item by remember{
        mutableStateOf(value = "something") //
    }
    FirstAprilTemplateTheme {
        Surface(
            modifier = Modifier.fillMaxSize(),
            color = MaterialTheme.colorScheme.background
        ){
            Greeting("Android")
        }
        Column() {
            Text(text = "To Do list!",
                fontSize = 32.sp,
                fontWeight = FontWeight.Bold,
                        modifier = Modifier.padding(12.dp))
        }

        OutlinedTextField(
            value = item,
                onValueChange = { item = it },
            label = {Text(text = "New Item")}
        )
        Row(){
            OutlinedTextField(
                value = item,
                onValueChange = { item = it },
                        label = {Text(text = "New Item")}
            )



        }
    }
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
    Text(
        text = "Hello $name!",
        modifier = modifier
    )
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    FirstAprilTemplateTheme {
        Greeting("Android")
    }
}

I need help with the current state of my app because I recently fixed Syntax errors that before gave me noticeable errors. I need to make sure this build of the app is working correctly, before I continue working on it. I am currently trying to make a simple to-do app, but am having a hard time. I am attempting to make this build work, so I can add more features to the app and make sure that it works correctly.

package com.example.firstapriltemplate

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activitypose.setContent
import androidx.activity.enableEdgeToEdge
import androidxpose.foundation.layout.fillMaxSize
import androidxpose.foundation.layout.padding
import androidxpose.material3.Scaffold
import androidxpose.material3.Text
import androidxpose.runtime.Composable
import androidxpose.ui.Modifier
import androidxpose.ui.tooling.preview.Preview
import com.example.firstapriltemplate.ui.theme.FirstAprilTemplateTheme
import androidxpose.foundation.layout.Column
import androidxpose.foundation.layout.Row
import androidxpose.material3.OutlinedTextField
import androidxpose.runtime.mutableStateOf
import androidxpose.runtime.remember
import androidxpose.ui.text.font.FontWeight
import androidxpose.ui.unit.dp
import androidxpose.ui.unit.sp
import androidxpose.material3.Surface
import androidxpose.material3.MaterialTheme
import androidxpose.runtime.getValue
import androidxpose.runtime.setValue
import java.util.concurrent.BlockingDeque



class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            App()
            FirstAprilTemplateTheme {
                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                    Greeting(
                        name = "Android",
                        modifier = Modifier.padding(innerPadding)
                    )
                }
            }
        }
    }
}

@Composable
fun App(){
    var item by remember{
        mutableStateOf(value = "something") //
    }
    FirstAprilTemplateTheme {
        Surface(
            modifier = Modifier.fillMaxSize(),
            color = MaterialTheme.colorScheme.background
        ){
            Greeting("Android")
        }
        Column() {
            Text(text = "To Do list!",
                fontSize = 32.sp,
                fontWeight = FontWeight.Bold,
                        modifier = Modifier.padding(12.dp))
        }

        OutlinedTextField(
            value = item,
                onValueChange = { item = it },
            label = {Text(text = "New Item")}
        )
        Row(){
            OutlinedTextField(
                value = item,
                onValueChange = { item = it },
                        label = {Text(text = "New Item")}
            )



        }
    }
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
    Text(
        text = "Hello $name!",
        modifier = modifier
    )
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    FirstAprilTemplateTheme {
        Greeting("Android")
    }
}
Share Improve this question edited Apr 1 at 2:40 UnusualAce77 asked Apr 1 at 1:33 UnusualAce77UnusualAce77 617 bronze badges New contributor UnusualAce77 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 15
  • @MikeM. I just fixed that error, but I still have about 18 other issues. – UnusualAce77 Commented Apr 1 at 1:37
  • @MikeM. Unfortunately, I added your OutlineTextField fix, but I'm still having issues with it being recognized as a syntax error. I added the new edits in the original post coding section. – UnusualAce77 Commented Apr 1 at 1:50
  • @MikeM. I added all of the edits you told me, however, I don't know where I need to fix the second modifier (I don't know where exactly to put the second comma). – UnusualAce77 Commented Apr 1 at 1:59
  • @MikeM. I just fixed the onValue change comma. I get a problem with none of the candidates is applicable here: Also, I'm having trouble with var item by remember{ mutableStateOf(value = "something") // } – UnusualAce77 Commented Apr 1 at 2:09
  • @MikeM. I also get an unresolved reference here with colors. line 57: color = MaterialTheme.colors.background – UnusualAce77 Commented Apr 1 at 2:11
 |  Show 10 more comments

1 Answer 1

Reset to default 2

Mike M, successfully answered my question and debugged the current state of my project.

ParseErrors are in XML files, like layouts and the AndroidManifest.xml. If it doesn't have the specific file listed in the error message, and you can't find it yourself easily by looking through each one, you might be able to catch it with code inspection: Main Menu > Code > Inspect Code…

发布评论

评论列表(0)

  1. 暂无评论