我在Visual Studio 2017社区版15.8.3中为Xamarin创建了一个新项目。然后我在MainPage.xaml
和cs
中添加了一些更改,现在在构建解决方案时遇到了这些错误。
错误指的是我没有碰到的styles.xml
。
我之前看到此错误,要求重新启动VS,重新启动计算机,清理obj
和bin
目录,升级VS等。
我不想盲目地做这些事情。
这个问题有系统的解决方案吗?
答案 0 :(得分:0)
这在针对Android 7.1的VS2017跨平台解决方案中为我工作:
在一个单独的项目中,上述解决方案无法解决我的错误,并且我还成功地执行了以下其他步骤:
import pygame as pg from pygame.math import Vector2 pg.init() LIGHTBLUE = pg.Color('lightskyblue2') DARKBLUE = pg.Color(11, 8, 69) screen = pg.display.set_mode((800, 600)) width, height = screen.get_size() clock = pg.time.Clock() # You need surfaces with an alpha channel for the masks. bluecar = pg.Surface((60, 30), pg.SRCALPHA) bluecar.fill((0,0,255)) BALL = pg.Surface((30, 30), pg.SRCALPHA) pg.draw.circle(BALL, [0,0,0], [15, 15], 15) ball_pos = Vector2(395, 15) ballrect = BALL.get_rect(center=ball_pos) ball_vel = Vector2(0, 0) mask_blue = pg.mask.from_surface(bluecar) mask_ball = pg.mask.from_surface(BALL) pos_blue = Vector2(740, 500) # Just use the pos vector instead of x, y. bluerect = bluecar.get_rect(center = pos_blue) vel_blue = Vector2(0, 0) # Replace x_change, y_change with vel_blue. # A constant value that you add to the y-velocity each frame. GRAVITY = .5 on_ground = False ground_y = height - 100 done = False while not done: for event in pg.event.get(): if event.type == pg.QUIT: done = True elif event.type == pg.KEYDOWN: if event.key == pg.K_a: vel_blue.x = -5 elif event.key == pg.K_d: vel_blue.x = 5 elif event.key == pg.K_w: if on_ground: # Only jump if the player is on_ground. vel_blue.y = -12 on_ground = False elif event.type == pg.KEYUP: if event.key == pg.K_a and vel_blue.x < 0: vel_blue.x = 0 elif event.key == pg.K_d and vel_blue.x > 0: vel_blue.x = 0 ball_vel.y += GRAVITY # Accelerate downwards. ball_pos += ball_vel # Move the ball. ballrect.center = ball_pos # Update the rect. # Bounce when the ball touches the bottom of the screen. if ballrect.bottom >= ground_y: # Just invert the y-velocity to bounce. ball_vel.y *= -0.7 # Change this value to adjust the elasticity. ball_vel.x *= .95 # Friction # Don't go below the ground. ballrect.bottom = ground_y ball_pos.y = ballrect.centery # Left and right wall collisions. if ballrect.left < 0: ball_vel.x *= -1 ballrect.left = 0 ball_pos.x = ballrect.centerx elif ballrect.right > width: ball_vel.x *= -1 ballrect.right = width ball_pos.x = ballrect.centerx # Add the GRAVITY value to vel_blue.y, so that # the object moves faster each frame. vel_blue.y += GRAVITY pos_blue += vel_blue bluerect.center = pos_blue # You have to update the rect as well. # Stop the object when it's near the bottom of the screen. if bluerect.bottom >= ground_y: bluerect.bottom = ground_y pos_blue.y = bluerect.centery vel_blue.y = 0 on_ground = True if bluerect.x < 0: bluerect.x = 0 pos_blue.x = bluerect.centerx elif bluerect.right > width: bluerect.right = width pos_blue.x = bluerect.centerx offset_blue = bluerect[0] - ballrect[0], bluerect[1] - ballrect[1] overlap_blue = mask_ball.overlap(mask_blue, offset_blue) if overlap_blue: # Blue collides with the ball. if vel_blue.x != 0: # Player is moving. ball_vel = Vector2(vel_blue.x, -17) else: # If the player is standing, I just update the vel.y. ball_vel.y = -17 # Draw everything. screen.fill(LIGHTBLUE) pg.draw.line(screen, (0, 0, 0), (0, ground_y), (width, ground_y)) screen.blit(bluecar, bluerect) # Blit it at the rect. screen.blit(BALL, ballrect) pg.display.update() clock.tick(60) pg.quit()
Xamarin.Android.Support.v7.AppCompat
又一次清理和构建,这些问题消失了……剩下了我能够解决的残余代码问题。
经过另一次清理和构建后,我收到另一个错误,我缺少以下Nuget参考:
Xamarin.Android.Support.Design
答案 1 :(得分:0)